fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int NWD(int a, int b)
  6. {
  7. while(a!=b)
  8.  
  9. if(a>b)
  10. a-=b;
  11. else
  12. b-=a;
  13.  
  14. return a;
  15. }
  16. int main()
  17. {
  18. int z;
  19. int x;
  20. int N;
  21. cin>> N;
  22. while(N!=0)
  23. {
  24. N--;
  25. cin>>z>>x;
  26. cout<<NWD(z,x)<<endl;
  27. }
  28. return 0;
  29. }
  30.  
Time limit exceeded #stdin #stdout 5s 3412KB
stdin
Standard input is empty
stdout
Standard output is empty