题目描述
Rist-Number is a kind of integers that should satisfy some restrictions. Define S as the set of all Rist-Numbers, then we have
- 1∈S
- 3×S∈S
- 7×S∈S
- 15×S∈S
- 31×S∈S
Obviously, S is an infinite set. Given n , judge whether n∈S is true.
输入格式
The input contains multiple test cases.
The first line of input contains an integer T(T≤100) , which denotes the number of test cases.
The following T lines describe all the queries, each with an integer n(1≤n≤10000) .
输出格式
For each test case, output True
if the statement is true, otherwise output False
.
输入样例
2
1
2
输出样例
True
False
不知为何用除法判断是否只含有3,7,15,31的素因数会WA, 可能是OJ数据有问题吧.
/*
USER_ID: test#birdstorm
PROBLEM: 210
SUBMISSION_TIME: 2014-04-01 12:35:16
*/
#include <stdio.h>
#include <stdlib.h>
#define For(i,m,n) for(i=(m);i<(n);i++)
#define MAXN 100005int a[MAXN];main()
{int t, n;scanf("%d",&t);a[1]=1;For(n,1,3000) if(a[n]) a[n*3]=a[n*7]=a[n*15]=a[n*31]=1;while(t--){scanf("%d",&n);if(a[n]==1) puts("True");else puts("False");}return 0;
}