GAMES, SPOJ WA

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]: SPOJ.com - Problem GAMES

Try to not use doubles for precise problems. Use strings. Doubles don’t keep a precise value.

But, it says that double can store precise data up to 6 places of decimal, and here the problem demands only 4 digits after decimal place. Then where is it getting wrong ? I cannot find any case which gives wrong answer on my local machine. Can you suggest some ?