-
Notifications
You must be signed in to change notification settings - Fork 2
/
GAMES - HOW MANY GAMES.cpp
64 lines (53 loc) · 1.1 KB
/
GAMES - HOW MANY GAMES.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b)
{
if(a<b)
return gcd(b,a);
if(b==0)
return a;
a%=b;
return gcd(b,a);
}
int main()
{
long long t;
cin>>t;
while(t--)
{
float deci;
string n;
cin>>n;
long long m;
m= atoi(n.c_str());
//cout<<m<<" ";
long long i,c=0,power,Flag=0, number=0;
for(int i=n.length()-1; i>=0; i--)
{
if(n[i]=='.')
{
Flag=1;
break;
}
else
{
c++;
}
}
if(Flag==1)
{
for(int i=0; i<n.length(); i++)
{
if(n[i]!='.')
{
number=number*10+n[i]-'0';
}
}
power=pow(10,c);
//cout<<number<<" "<<c<<" "<<power;
cout<<power/gcd(number,power)<<"\n" ;
}
else
cout<<"1\n";
}
}