fork download
  1. #include<iostream>
  2. #include<cmath>
  3. #include<algorithm>
  4. #include<string>
  5. #include<iomanip>
  6. using namespace std;
  7. int main(){
  8. long long x, y;
  9. cin >> x >> y;
  10. if (x<0) x *= -1;
  11. if (y<0) y *= -1;
  12. if (x>y) swap(x, y);
  13. while (x){
  14. long long r = y%x;
  15. y = x;
  16. x = r;
  17. }
  18. cout << y << endl;
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 4180KB
stdin
Standard input is empty
stdout
16