#include <iostream>
#include <cmath>
using namespace std;
long gcd(long a, long b)
{
if(b != 0)
{
long t = b;
b = a % b;
a = t;
return gcd(a, b);
}
return a;
}
int main()
{
int t, n;
string s;
cin >> t;
cin.get();
long num;
long number;
int count;
bool flag;
while(t--)
{
cin >> s;
count = 0;
number = 0;
flag = false;
num = 1;
for(int i=s.size()-1; i>=0; i--)
{
if(s[i]=='.')
{
flag=true;
break;
}
else
{
count++;
}
}
for(int i=0; i<s.size(); i++)
{
if(s[i]!='.')
{
number=number*10 + (s[i]-48);
}
}
if(flag)
{
num = pow(10, count);
}
long g = gcd(number, num);
cout << num / g << endl;
}
return 0;
}
Comments
Post a Comment