fork(2) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int ile;
  8.  
  9. cin>>ile;
  10.  
  11. int a[ile];
  12. int b[ile];
  13. int x[ile];
  14. int y[ile];
  15.  
  16. for(int i=0; i<ile; i++)
  17. {
  18. cin>>a[i];
  19. cin>>b[i];
  20.  
  21. x[i]=a[i];
  22. y[i]=b[i];
  23. }
  24.  
  25.  
  26. for(int i=0; i<ile; i++)
  27. {
  28.  
  29. while(true)
  30. {
  31. if(x[i]>y[i])
  32. {
  33. y[i]=y[i]+b[i];
  34. }
  35. if (x[i]<y[i])
  36. {
  37. x[i]=x[i]+a[i];
  38. }
  39. else
  40. {
  41. cout<<x[i];
  42. cout<<endl;
  43. break;
  44. }
  45. }
  46. }
  47.  
  48. return 0;
  49. }
Success #stdin #stdout 0s 15232KB
stdin
2
11 22
12 15
stdout
22
60