看到题目,十分浓厚的数论色彩,在纸上画了画,发现没啥思路。
于是看了题解,发现了一个精妙绝伦的操作:暴力观察
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
const int maxn = 1e5+7;
int check(int x,int y,int stp)
{
if(stp>=10004) return 0;
if(x==0 && y==0) return 1;
return check(x^y,abs(x-y),stp+1);
}
int main()
{
for(int i=1;i<=100;i++)
{
for(int j=1;j<=100;j++)
{
printf("%d\n",check(i,j,0));
}
}
return 0;
}
通过上述程序可以看出,在100*100的范围内,所有的点都满足条件。于是大胆推测,在题目的范围内,所有的点都是满足条件的。
于是答案就呼之欲出了。
此题的启发无疑是巨大的:在题目没有什么思路的时候,不妨通过一些暴力的手法来找到题目中的潜在关系。有时候是正着打表,有时候是逆推打表。注意这个技巧。