hdu 1729 Stone Game

//Time 0ms, Memory 288K
#include<iostream>
#include<cmath>
using namespace std;
int mex(int s,int c)
{
    int q=sqrt(s*1.0);
    while(q+q*q>=s) q--;
    if(q<c) return s-c;
    return mex(q,c);
}
int main()
{
    int i,n,s,c,t=1;
    while(cin>>n && n)
    {
        int ans=0;
        for(i=0;i<n;i++)
        {
            cin>>s>>c;
            ans^=mex(s,c);
        }
        cout<<"Case "<<t++<<":"<<endl;
        if(ans) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

原文地址:https://www.cnblogs.com/java20130726/p/3218198.html