Witzov Game game Theory Direct simulation can be worth mentioning is that the problem almost all the online problems are not considered only from the small heap to get the situation, so in similar 19 20 when the data appears, they are wrong only output 1 2 and not 12 20
1#include <cstdio>2 3#include <cmath>4 5#include <map>6 7#include <string.h>8 9 #defineINF 0x3f3f3f3fTen One Const intmaxn=1000000; A - using namespacestd; - the intb; - - BOOLJudgeintAintb) { - + returna== (int) ((b-a) * (sqrt (5.0)+1)/2); - } + A intMain () at { - while(SCANF ("%d%d", &a,&b)!=eof&& (a| |b)) { -map<int,int>Flag; - if(judge (A, B)) { -printf"0\n"); -}Else { inprintf"1\n"); - for(intI=0, j=0; i<=a;i++){ to if(!flag[i]&&!flag[i+J]) { + //printf ("%d%d\n", i,i+j); -flag[i]=flag[i+j]=1; the if(a-i==b-i-j&&a>i&&b>i+j) *printf"%d%d\n", i,i+j); $ /*else if ((a==i+j&&b>i) | | | (a==i&&i+j<b) | | (B==i+j&&a>i)) printf ("%d%d\n", i,i+j);*/Panax NotoginsengJ + +; - } the } + flag.clear (); A for(intI=0, j=0; i<=a;i++){ the if(!flag[i]&&!flag[i+J]) { + //printf ("%d%d\n", i,i+j); -flag[i]=flag[i+j]=1; $ /*if (a-i==b-i-j&&a>i&&b>i+j) $ printf ("%d%d\n", i,i+j);*/ - if((a==i+j&&b>i) | | (a==i&&i+j<b) | | (B==i+j&&a>i)) printf"%d%d\n", i,i+j); -J + +; the } - }Wuyi } the } - return 0; Wu}
View Code
This question reminds us, on the Internet to see the problem, no matter how big Daniel wrote, also must bring their own thinking.
hdu2177----(2 piles) Stone game