Cod sursa(job #29841)
Utilizator | Data | 10 martie 2007 23:27:14 | |
---|---|---|---|
Problema | A+B | Scor | 80 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.42 kb |
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int A,B,x;
freopen("adunare.in","r",stdin);
freopen("adunare.out","w",stdout);
scanf("%d%d", &A,&B);
srand(A+B);
while(A!=0 && B!=0)
{
x = rand()&1;
if(rand()&1)
A-=x, B+=x;
else
A+=x, B-=x;
}
if(A)
printf("%d\n", A);
else
printf("%d\n", B);
return 0;
}