HDU 5675 ztr loves math



    ztr loves math
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 96    Accepted Submission(s): 53


Problem Description

ztr loves research Math.One day,He thought about the "Lower Edition" of  triangle equation set.Such as n=x2−y2n=x^{2}-y^{2}.

He wanted to know that ,for a given number n,is there a positive integer solutions?

 


Input

There are T test cases.
The first line of input contains an positive integer T(T<=106)T(T<=10^{6}) indicating the number of test cases.

For each test case:each line contains a positive integer ,n<=1018n <=10^{18}.

 


Output

If there be a positive integer solutions,print TrueTrue,else print FalseFalse

 


Sample Input

4
6
25
81
105


 


Sample Output

False
True
True
True

Hint
For the fourth case,$105 = 13^{2}-8^{2}$
 


 


Source

 BestCoder Round #82 (div.2) 

 


Recommend

wange2014   |   We have carefully selected several similar problems for you:  5679 5678 5677 5676 5674

涉及一个数学知识:

设这两个数分别m、n,
设m>n,
即智慧数=m2-n2=(m+n)(m-n),
又∵mn是非0的自然数,
∴m+n和m-n就是两个自然数,
要判断一个数是否是智慧数,可以把这个数分解因数,分解成两个整数的积,看这两个数能否写成两个非0自然数的和与差.
(k+1)2-k2=2k+1,(K+1)2-(k-1)2=4k,每个大于1的奇数与每个大于4且是4的倍数的数都是智慧数,而被4除余数为2的偶数都不是智慧数,最小智慧数为3,从5开始,智慧数是5,7,8,9,11,12,13,15,16,17,19,20…即2个奇数,1个4的倍数,3个一组依次排列下去.
显然1不是“智慧数”,而大于1的奇数2k+1=(k+1)2-k2,都是“智慧数”. 因为:4k=(k+1)2-(k-1)2,所以大于4且能被4整除的数都是“智慧数”而4不是“智慧数”,由于x2-y2=(x+y)×(x-y)(其中x、y∈N),当x,y奇偶性相同时,(x+y)×(x-y)被4整除.当x,y奇偶性相异时,(x+y)*(x-y)为奇数,所以形如4k+2的数不是“智慧数”在自然数列中前四个自然数中只有3是“智慧数”.此后每连续四个数中有三个“智慧数”.

#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    __int64 n,t;
	scanf("%I64d",&t);
	while(t--)
	{
		scanf("%I64d",&n);
		if(n<3||n==4||n%4==2)
		{
			printf("False\n");
		}
	    else
	    {
	    	printf("True\n");
		}
	}
	return 0;
 } 

 

你可能感兴趣的:(HDU 5675 ztr loves math)