BUPT OJ210 Rist-Number

44 篇文章 3 订阅

题目描述

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值