码迷,mamicode.com
首页 > 其他好文 > 详细

Euclid's Game

时间:2019-03-16 00:25:22      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:==   取反   define   include   end   ++   ret   mes   class   

博弈论

如果a/b>=2则先手必胜,否则就对(b,a-b)的情况取反 a可以整除b的时候也是必赢的

要保证a>b

#include<bits/stdc++.h> 
#define ll long long
using namespace std;

ll a,b;


int main()
{
    while(cin>>a>>b)
    {
        if(a==0 && b==0)    break;
        
        int times = 1;
            if(a<b)
                swap(a,b);
        while(a%b && a/b==1)
        {
            a-=b;
            if(a<b)
                swap(a,b);
            times^=1;
    
        }
        if(!times)
            cout << "Ollie wins" << endl;
        else 
            cout << "Stan wins" << endl;    
    }
    
    return 0;
}

uva 10368

Euclid's Game

标签:==   取反   define   include   end   ++   ret   mes   class   

原文地址:https://www.cnblogs.com/xxrlz/p/10540283.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!