I am getting WA in [GAMES][1]. My code is
#include <cstdio>
using namespace std;
main()
{
int t;
scanf("%d",&t);
while(t--)
{
double avg;
scanf("%lf",&avg);
avg*=10000;
long long b=static_cast<long long>(avg);
//printf("%lf %lld\n",avg,b);
long long a=10000;
while(b%a!=0)
{
long long tmp=b%a;
b=a;
a=tmp;
}
printf("%lld\n",10000/a);
}
return 0;
}
I want to this, without using string. I am also not using any comparision with the float variables, so
no error whatsoever should crop up due to using, float. Am I correct ??
[1]: http://www.spoj.com/problems/GAMES/