Cod sursa(job #29869)
Utilizator | Data | 11 martie 2007 18:16:18 | |
---|---|---|---|
Problema | A+B | Scor | 90 |
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()&3;
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;
}