Posted by: dzikrina on: February 6, 2011

Bersama kita menjalin rasa ukhuwwah
Yang telah bersemi
Berawal dari rasa cinta Ilahi
Menjelma rasa cinta sejati
Seindah senyum manis
Matahari bersinar semarakkan pagi
Dedaunan melambai hijau nan berseri
Kicauan burung damaikan hati
Oo.. berpadulah,
hapuskan sgala rasa amarah
Pupus sudah rasa dendam
padamkan bara api permusuhan
Sesegar mawar bertaburan,
harum mewangi rasa persaudaraan…
Posted by: dzikrina on: October 29, 2010
//checking phytagoras rectangle
#include
#include
#include
using namespace std;
int main()
{
int input[3];
int sum, C;
while (cin >> input[0] >> input[1] >> input[2])
{
if ( (input[0]== 0) && (input[1] == 0) && (input[2]== 0))
break;
sort( input, input+3 );
sum = ( (input[0]*input[0])+(input[1]*input[1]));
C = (input[2]*input[2]);
if ( sum == C)
cout << "right" << endl;
else
cout << "wrong" << endl;
}
return 0;
}
Posted by: dzikrina on: October 23, 2010
//http://uva.onlinejudge.org/external/113/11388.html
//http://github.com/andmej/acm/tree/master/11388%20-%20GCD%20LCM
//11388 PROBLEM d: gcd lcm
#include
using namespace std;
int main()
{
int t;
unsigned int g, l;
cin >> t;
while (t--)
{
cin >> g >> l;
if ( g > l || l % g != 0)
cout << "-1" << endl;
else
cout << g << " " << l << endl;
}
//system ("pause");
return 0;
}
Posted by: dzikrina on: October 23, 2010
//http://uva.onlinejudge.org/external/116/11636.html
// 11636 Hello World!
#include
#include
using namespace std;
int main()
{
int mycase=0, N;
double k;
while (1)
{
cin >> N;
if (N <0)
break;
k = ceil(log(N)/log(2));
int i=0;
mycase ++;
cout <<"Case " << mycase << ": " << k << endl;
}
return 0;
}
Posted by: dzikrina on: May 7, 2010
#include
//#include
using namespace std;
typedef long long LL;
LL A,B,C;
LL recur(LL b){
//cout<<b<<endl;
if(b==1) return A%C;
LL t1 = recur(b/2);
t1 = (t1*t1)%C;
if(b%2==1) t1 = (t1*A)%C;
return t1;
}
/*LL pow(LL X,int p){
LL ret = 1;
for(int i=0;i<p;++i) ret=(ret*X)%C;
return ret;
}
LL recur10(LL b){
if(b<10) return pow(A,b);
LL t1 = recur10(b/10);
t1 = pow(t1,10);
for(int i=0;i> T;
for (int i=0; i>A >> B >> C;
cout<<recur(B)<<endl;
}
//system("pause");
return 0;
}
Posted by: dzikrina on: January 22, 2010
http://acm.tju.edu.cn/toj/vcontest/contest5472.html
PROBLEM B
B. Serious Cow Tag
/*
TASK:
LANG: C++
USER: smilitude1
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
struct data { int x,y; } ;
int main() {
data d[1005];
int n;
bool ok[1005]; SET( ok, 0 );
scanf("%d",&n);
for(int i=0; i<n; i++) scanf("%d %d",&d[i].x, &d[i].y);
int st = -1;
for(int t=0; t<n-1; t++) {
int mindist, id;
mindist = -1;
++ st, st %= n;
while( ok[ st ] ) ++st, st %= n;
for(int i=0; i<n; i++) if( !ok[i] && i != st ) {
int dist = ( d[i].x - d[st].x ) * ( d[i].x - d[st].x ) + ( d[i].y - d[st].y ) * ( d[i].y - d[st].y );
if( mindist == -1 || dist < mindist ) mindist = dist, id = i;
}
ok[ id ] = true;
}
for(int i=0; i<n; i++) if( !ok[i] ) printf("%d\n",i+1);
return 0;
}
PROBLEM C
The Flower Garden
#include
using namespace std;
int main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
int row,garden[10010],numr;
int sslot, seq, count=0;
cin >> row;
cin >> numr;
for (int j=0; j<row; j++) garden[j]=0;
for (int i=0; i> sslot;
cin >> seq;
for (int k=(sslot-1); k<row; k+=seq)
garden [k]=1;
}
int ans = 0;
for(int i=0; i<row; i++) if( garden[i] == 0 ) ans ++;
cout << ans << endl;
return 0;
}
PROBLEM D
Sudoku
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main() {
int total, nflower;
while( scanf("%d%d",&total, &nflower ) == 2 ) {
bool flag[total+1];
int a,b;
memset( flag, 0, sizeof( flag ));
for(int i=0; i<nflower; i++) {
scanf("%d%d",&a, &b );
for(int j=a; j<=total; j+=b) flag[j] = true;
}
int ans = 0;
for(int i=1; i<=total; i++) if(flag[i] == 0 ) ans++;
printf("%d\n",ans);
}
return 0;
}
PROBLEM E
RED AND BLACK
/*
TASK: TJU 1851
ALGO: backtracking
LANG: C++
USER: smilitude
TIME:
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for( __typeof(b) i=(a); i=(b); i--)
#define SET(t,v) memset((t), (v), sizeof(t))
#define sz size()
#define pb push_back
#define i64 long long
#define ALL(x) x.begin(), x.end()
#define FORIT(i, m) for (__typeof((m).begin()) i=(m).begin(); i!=(m).end(); ++i)
#define REV(x) reverse( ALL( x ) )
#define IO freopen("","r",stdin); freopen("","w",stdout);
#define bug(x) cerr << __LINE__ <<" "<< #x " = " << x << endl
char g[10][10];
int used[3][3][10], row[9][10], col[9][10];
bool done;
int mid = 15;
void print() {
REP(i,9) {
REP(j,9) printf("%d", g[i][j] );
puts("");
}
// puts("");
}
void solve( int r, int c ) {
if( r == 9 ) {
done = 1;
print();
}
else if( c == 9 ) solve( r+1, 0 );
else if( g[r][c] != 0 ) solve( r, c+1 );
else {
int rr = r/3, cc = c/3;
FOR(i,1,9) {
if( row[r][i] || col[c][i] || used[rr][cc][i] ) continue;
row[r][i] = 1;
col[c][i] = 1;
used[rr][cc][i] = 1;
g[r][c] = i;
solve( r, c+1 );
if( done ) return;
row[r][i] = 0;
col[c][i] = 0;
used[rr][cc][i] = 0;
}
g[r][c] = 0;
}
}
int main() {
int t;
scanf("%d",&t);
while( t-- ) {
REP(i,9) scanf("%s",g[i]);
// building
SET( used, 0 ); SET( row, 0 ); SET( col, 0 );
REP(r,9) REP(c,9) {
if( g[r][c] == '0' ) g[r][c] = 0;
else {
g[r][c] -= '0';
row[r][ g[r][c] ] = 1;
col[c][ g[r][c] ] = 1;
used[ r/3 ][ c/3 ][ g[r][c] ] = 1;
}
}
// processing
done = 0;
solve(0,0);
}
return 0;
}
ALL THE CODES BY MY TUTORS, BRO IQRAM N BRO EMIR
IIUM PROGRAMMING TRAINING 2010
Posted by: dzikrina on: January 22, 2010
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int a[205], b[205];
int na, nb;
int main() {
int t;
cin >> t;
while( t– ) {
cin >> na;
for(int i=0; i> a[i];
cin >> nb;
for(int i=0; i> b[i];
int ans = 0;
for(int i=0; i<na; i++)
for(int j=0; j<nb; j++)
if( (a[i] + b[j]) == 0 ) ans++;
cout << ans << endl;
}
return 0;
}
Posted by: dzikrina on: December 21, 2009
fourth class
here are some sample of html expertise:
Here’s some big text
Here’s some smaller text
And here’s a new paragraph to round things out.
this text is center
this is the example of the paragraph and make it right
this is the example of the paragraph and make it left
this is the example of the paragraph and make it center
This is a default order list
This is a big letter order list
This is a small letter order list
This is a default unorder list
This is a nested unorder list
This is a square unorder list
This is a circle list
Posted by: dzikrina on: December 19, 2009
// 1001 HELLO WORLD!
#include <iostream>
using namespace std;
int main()
{
int num;
while (scanf (“%d”, &num) != EOF)
{
char C = static_cast<char> (num);
cout << C;
}
cout << endl;
system (“pause”);
return 0;
}
Posted by: dzikrina on: December 19, 2009
// QUICK CHANGEĀ OR FAST CHANGE
#include <iostream>
using namespace std;
int main()
{
int numCase;
int change;
int quarter, dime, nickel, penny;
int Q, D, N, P;
int rem1, rem2, rem3;
#define QUARTER 0.25
#define DIME 0.10
#define NICKEL 0.05
#define PENNY 0.01
#define BASE 100
Q = static_cast <int> (BASE*QUARTER);
D = static_cast <int> (BASE*DIME);
N = static_cast <int> (BASE*NICKEL);
P = static_cast <int> (BASE*PENNY);
cin >> numCase;
for (int i=0; i<numCase; i++)
{
cin >> change;
quarter = (change/Q);
rem1 = (change%Q);
dime = (rem1/D);
rem2 = (rem1%D);
nickel = (rem2/N);
rem3 = (rem2%N);
penny = (rem3/P);
cout << i+1 <<” “<< quarter << ” QUARTER(S), ” << dime << ” DIME(S), ” << nickel <<” NICKEL(S), “
<< penny << ” PENNY(S)” << endl;
}
return 0;
}
Recent Comments