题目:http://poj.org/problem?id=1067
好像不用分析了吧
枚举必败情况( a < b ):
a | b | b-a |
---|---|---|
0 | 0 | 0 |
1 | 2 | 1 |
3 | 5 | 2 |
4 | 7 | 3 |
6 | 10 | 4 |
读入!相减!判断!AC!
正常代码在此
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int a, b, c;
int main() {
while(scanf("%d%d", &a, &b) == 2) {
if(a > b) swap(a, b);
c = b - a;
if(a == (int)((double)c*(sqrt(5.0)+1.0)/2.0)) printf("0\n");
else printf("1\n");
}
return 0;
}
是不是很简单?
还有一份极致压行的
以博主的水平只能这样了
#include<cstdio>
int a,b;int main(){while(scanf("%d%d",&a,&b)==2)if((a>b?b:a)==(int)((double)(a>b?a-b:b-a)*1.618033989))printf("0\n");else printf("1\n");}