标签:io os for sp c amp r ios as
//,在威佐夫博奕的基础上新增加了一条要求:就是如果在赢得条件下,输出第一步怎么走。 # include <stdio.h> # include <algorithm> # include <iostream> # include <math.h> # include <string.h> using namespace std; int main() { int a,b,i,k; while(~scanf("%d%d",&a,&b),a+b) { k=b-a; k=k*(sqrt(5.0)+1)/2; if(k==a) printf("0\n"); else { printf("1\n"); for(i=1; i<=a; i++) //取两堆 { int n=a-i; int m=b-i; k=m-n; k=k*(sqrt(5.0)+1)/2; if(k==n)//后手赢 相当与第一次的先手赢 printf("%d %d\n",n,m); } for(i=0; i<=b-1; i++) //只取一堆,取大堆 能得出全部情况 { int n=i; int m=a; if(n>m) swap(n,m); k=m-n; k=k*(sqrt(5.0)+1)/2; if(k==n) printf("%d %d\n",n,m); } } } return 0; }
标签:io os for sp c amp r ios as
原文地址:http://blog.csdn.net/lp_opai/article/details/39480875