Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* e793 - 1 */
- #include <cstdio>
- using namespace std;
- using int64 = long long;
- class A;
- A* arr[2];
- class A
- {
- public:
- virtual int64 gcd(int64 a, int64 b)
- {
- return a;
- }
- };
- class B : public A
- {
- public:
- virtual int64 gcd(int64 a, int64 b)
- {
- return arr[!!(a % b)]->gcd(b, a % b);
- }
- };
- int64 gcd_sol(int64 X, int64 Y)
- {
- A a;
- B b;
- arr[!!!Y] = &a;
- arr[!!Y] = &b;
- int64 value = arr[1]->gcd(X, Y);
- return value;
- }
- int main()
- {
- int64 X, Y;
- while (scanf("%lld %lld", &X, &Y), X || Y)
- {
- printf("%lld\n", gcd_sol(X, Y));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement