HDU(1525)Euclid's Game

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
using namespace std;
int main() {
    int a,b;
    while(scanf("%d%d",&a,&b)&&(a+b)){
        if(a<b) swap(a, b);
        int flag = 1;
        while(1){
            if(a == b || a >= 2*b)
                break;
            else{
                a = a - b;
                swap(a,b);
                flag = !flag;
            }
        }
        if(flag)
            printf("Stan wins\n");
        else
            printf("Ollie wins\n");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/Roly/p/3079404.html