fork download
  1. //Bismillahir Rahmanir Rahim
  2. /******A.K.M Harunur Rashid******/
  3. /***********Template Starts Here***********/
  4. #include<iostream>
  5. #include<cstdio>
  6. #include<cstring>
  7. #include<cmath>
  8. #include<cctype>
  9. #include<cstdlib>
  10. #include<cassert>
  11. #include<string>
  12. #include<vector>
  13. #include<set>
  14. #include<stack>
  15. #include<queue>
  16. #include<map>
  17. #include<algorithm>
  18.  
  19. using namespace std;
  20.  
  21. #define MEM(a,b) memset(a,b,sizeof(a))
  22. #define CLR(a) memset(a,0,sizeof(a))
  23. #define MAX(a,b) ((a)>(b)?(a):(b))
  24. #define MIN(a,b) ((a)>(b)?(b):(a))
  25. #define ABS(a) ((a)>0? (a):(-(a)))
  26. #define SQ(a) ((a)*(a))
  27. #define SZ(a) (int)a.size()
  28. #define FORN(i,n) for(i=1;i<=n;i++)
  29. #define FORAB(i,a,b) for(i=a;i<=b;i++)
  30. #define ALL(V) V.begin(),V.end()
  31. #define pb(a) push_back(a)
  32. #define pr(a) cout<<a<<endl
  33. #define SQR(a) ((a)*(a))
  34. #define pf printf
  35. #define sf scanf
  36. #define mp make_pair
  37. #define Swap(a,b) (a^=b,b^=a,a^=b)
  38. #define PI acos(-1)
  39. #define x first
  40. #define y second
  41. #define eps 1e-7
  42.  
  43. typedef int D;
  44. typedef long long int LLD;
  45. typedef unsigned long long int LLU;
  46. typedef vector<D> VI;
  47. typedef set<D> SI;
  48. typedef vector<D>::iterator Viti;
  49.  
  50. /***********Template Ends Here***********/
  51.  
  52. int main()
  53. {
  54. LLU w,h;
  55. while(1)
  56. {
  57. cin>>w>>h;
  58. if(w==0 && h==0) break;
  59. if(w==h)
  60. printf("1\n");
  61. else
  62. {
  63. if(w<h) Swap(w,h);
  64. if(w%h==0) printf("%llu\n",w/h);
  65. else printf("%llu\n",w*h/__gcd(w,h));
  66. }
  67. }
  68. return 0;
  69. }
  70.  
  71.  
Success #stdin #stdout 0s 3344KB
stdin
2 3
1 2
0 0
stdout
6
2