fork(1) download
  1. #include <iostream>
  2.  
  3. long int nNWD(long int nLiczba1, long int nLiczba2)
  4. {
  5. long int c=0;
  6. while(nLiczba2!=0)
  7. {
  8. c=nLiczba1%nLiczba2;
  9. nLiczba1=nLiczba2;
  10. nLiczba2=c;
  11. }
  12. return nLiczba1;
  13. }
  14.  
  15.  
  16. int main()
  17. {
  18. int nLiczbaZestawow;
  19.  
  20. std::cin>>nLiczbaZestawow;
  21.  
  22. long int nWymiarPierwszy, nWymiarDrugi;
  23.  
  24. for(int i=1; i<=nLiczbaZestawow; i++)
  25. {
  26. std::cin>>nWymiarPierwszy>>nWymiarDrugi;
  27. std::cout<<nNWD(nWymiarPierwszy, nWymiarDrugi)<<std::endl;
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 3472KB
stdin
2
2000 1000
999983 1000000
stdout
1000
1