当前位置: 代码迷 >> 综合 >> BUPT OJ210 Rist-Number
  详细解决方案

BUPT OJ210 Rist-Number

热度:93   发布时间:2024-01-12 05:24:41.0

题目描述

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. 1S
  2. 3×SS
  3. 7×SS
  4. 15×SS
  5. 31×SS

Obviously,  S  is an infinite set. Given  n , judge whether  nS  is true.

输入格式

The input contains multiple test cases.

The first line of input contains an integer  T(T100) , which denotes the number of test cases.

The following  T  lines describe all the queries, each with an integer  n(1n10000) .

输出格式

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;
}


  相关解决方案