Advertisement
Emiliatan

e793-2

Dec 30th, 2019
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. /* e793 - 2 */
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. using int64 = long long;
  7.  
  8. typedef int64(*Fun)(int64 a, int64 b);
  9. struct gcd_solver
  10. {
  11.     Fun gcd;
  12. };
  13.  
  14. gcd_solver arr[2] = { [](int64 a, int64 b) { return a; }, [](int64 a, int64 b) { return arr[!!(a % b)].gcd(b, a % b); } };
  15.  
  16. int main()
  17. {
  18.     int64 X, Y;
  19.  
  20.     while (scanf("%lld %lld", &X, &Y), X || Y)
  21.     {
  22.         printf("%lld\n", arr[!!Y].gcd(X, Y));
  23.     }
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement