fork download
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4. int gcd(int a,int b)
  5. {
  6. if(b==0)
  7. return a;
  8. else
  9. gcd(b,a%b);
  10. }
  11.  
  12. int main()
  13. {
  14. int t;
  15. cin>>t;
  16. while(t--)
  17. {
  18. string s1;
  19. cin>>s1;
  20. int x=s1.length(),a=0,b=1;
  21. int i=0;
  22.  
  23. while(s1[i]!='.'&&i!=x-1)
  24. {
  25. i++;
  26.  
  27. }
  28.  
  29. if(i==x-1)
  30. cout<<"1"<<endl;
  31. else{
  32.  
  33. for(int j=i+1;j<x;j++)
  34. {
  35. a=a*10+(s1[j]-'0');
  36. b=b*10;
  37.  
  38. }
  39. cout<<b/gcd(b,a)<<endl;
  40. }}
  41. }
  42.  
Success #stdin #stdout 0s 2864KB
stdin
2
0.3332
0.3334
stdout
2500
5000