您的位置:首页 > 其它

HDU 5675 ztr loves math(技巧枚举)

2016-05-03 10:25 267 查看
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5675

代码:

#include<stdio.h>
#include<string.h>
#include<math.h>

using namespace std;

int main()
{
int t;
scanf("%d",&t);

while(t--)
{
int n;
scanf("%d",&n);
int temp=sqrt(n);
int flag=1;

for(int i=temp; i>0; i--)
{
if( (n%i==0) && (i!=n/i) )
{
if((n/i+i)%2==0)
{
//printf("%d\n",i);
flag=0;
break;
}
}
}

if(flag==0)
printf("True\n");
else
printf("False\n");
}
}


枚举 x-y 前见天刚做过类似的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: