HDU 5675 ztr loves math(技巧枚举)

来源:互联网 发布:全球聊天软件排名 编辑:程序博客网 时间:2024/06/04 00:49

题目: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   前见天刚做过类似的。

0 0
原创粉丝点击