#include<cstdio> #include<cmath> #include<algorithm> using namespace std; int main(){ int a,b; while(~scanf("%d%d",&a,&b)&&(a||b)){ if(a>b) swap(a,b); int k=b-a; int tmp=(int)(k*(sqrt(5)+1)/2.0); if(tmp==a)//Singular situation, whoever wins first loses puts("0"); else{ puts("1"); //Two piles are taken at the same time, k remains unchanged, and judge whether ak is less than a if(a>tmp){ printf("%d %d\n",tmp,b-(a-tmp)); } //Take a bunch and enumerate all the differences between 0~b for(int i=0;i<=b;i++){ int tmp2=(int)(i*(sqrt(5)+1)/2.0); //Prevent repetition, for example, 7 10 take two piles or one pile will have 4 7 if(tmp2==tmp) continue; if(tmp2==a&&b>tmp2+i||tmp2+i==a||tmp2+i==b&&a>tmp2){ printf("%d %d\n",tmp2,tmp2+i); } } } } return 0; }
hdu 2177 Take (2 piles) stones game (Wyzhov game)
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325778267&siteId=291194637
Recommended
Ranking