fork download
  1. #include <iostream>
  2. using namespace std;
  3. int f(int a, int b)
  4. {
  5. if(a==b)
  6. return a;
  7. if(a > b)
  8. return f(a-b, b);
  9. return f(a, b-a);
  10. }
  11.  
  12. int a,b,c,d,i,n,j,l,x,y,z,k;
  13. int main() {
  14. cin>>x>>y>>z>>k;
  15. a=f(x, 100);if(a==1) a=x;
  16. b=f(y, 100);if(b==1) b=y;
  17. c=f(z, 100);if(c==1) c=z;
  18. d=f(k, 100);if(d==1) d=k;
  19. //cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
  20. if(100%x==0)
  21. a=100/x;
  22. if(100%y==0)
  23. b=100/y;
  24. if(100%z==0)
  25. c=100/z;
  26. if(100%k==0)
  27. d=100/k;
  28. for(i=a;;i++)
  29. {
  30. if(i%a==0 && i%b==0)
  31. {break;}
  32.  
  33. }
  34. for(j=c;;j++)
  35. {
  36. if(j%c==0 && j%d==0)
  37. {break;}
  38.  
  39. }
  40. if(i>j)
  41. {
  42. for(l=i;;l++)
  43. {
  44. if(l%i==0 && l%j==0)
  45. {break;}
  46.  
  47. }
  48. }
  49. else
  50. {
  51. for(l=j;;l++)
  52. {
  53. if(l%i==0 && l%j==0)
  54. {break;}
  55.  
  56. }
  57. }
  58. if(l>100)
  59. cout<<"100"<<endl;
  60. else
  61. cout<<l;
  62. return 0;
  63. }
Success #stdin #stdout 0s 4304KB
stdin
42 39 9 10
stdout
100