對於給定的一個正整數n, 判斷n是否能分紅若干個正整數之和 (能夠重複) ,
其中每一個正整數都能表示成兩個質數乘積。ios
第一行一個正整數 q,表示詢問組數。
接下來 q 行,每行一個正整數 n,表示詢問。code
q 行,每行一個正整數,爲 0 或 1。0 表示不能,1 表示能。get
$\texttt{input#1}$
5
1
4
5
21
25input
$\texttt{output#1}$
0
1
0
1
1string
樣例解釋:
4 = 2 * 2
21 = 6 + 15 = 2 * 3+3 * 5
25 = 6 + 9 + 10 = 2 * 3+3 * 3+2 * 5
25 = 4 + 4 + 4 + 4 + 9 = 2 * 2+2 * 2+2 * 2+2 * 2+3 * 3it
30%的數據知足:q<=20,n<=20
60%的數據知足:q<=10000,n<=5000
100%的數據知足:q<=10^5,n<=10^18io
4x + 6y 能夠湊出大於等於4的所有偶數,又由於4x + 6y 能夠拆成x個2 * 2及y個2 * 3相加。因此大於等於4的偶數所有可拆。大於等於13的奇數徹底能夠表示成大於等於4的偶數加9,大於等於4的偶數所有可拆,9也可拆,因此大於等於13的奇數也可拆。小於等於12的數中4,6,8,9,10,12是可拆的,0,1,2,3,5,7,11是不可拆的。因此大於等於12的全可拆,小於12的只有4,6,8,9,10可拆。class
#include<iostream> #include<cstring> #include<string> #include<cstdio> #include<algorithm> typedef long long ll; ll q,n; inline void read(ll &T) { ll x=0;bool f=0;char c=getchar(); while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();} while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();} T=f?-x:x; } int main() { read(q); while(q--) { read(n); if(n>=12) puts("1"); else { if(n==4||n==6||n==8||n==9||n==10) puts("1"); else puts("0"); } } return 0; }