Gym - 102448E Everybody loves acai (打表)

Description
Gabriel is a student from UFPE that loves acai (he really loves it). As he is really passionate about it, he became very picky about how much acai a perfect bowl should have.

A bowl is said to be perfect if the volume of acai in it is a perfect number.

A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself.

Gabriel decided to go to different restaurants and ask how much acai they have. Your task is to help him get the biggest perfect bowl on each of them or declare it is impossible.

Input
The first line of input contains an integer n ( 1 ≤ n ≤ 2 ⋅ 1 e 6 ) (1≤n≤2⋅1e6) (1n21e6), the number of restaurants Gabriel will visit. Each of the next n lines contains an integer ki ( 1 ≤ k i ≤ 2 ⋅ 1 e 6 ) (1≤ki≤2⋅1e6) (1ki21e6), the amount of acai the i-th restaurant has.

Output
Output should consist of n lines. The i-th of them must contain an integer ai, the biggest acai Gabriel can have at the i-th restaurant, or −1 if it’s not possible to have a perfect acai.

Example
Input
2
8
5

Output
6
-1

Main idea & Solution
求2e6内的完美数的个数
打表发现一共只有4个

Code

int res[MX];
int main(){
    int n;scanf("%d",&n);
    for(int i = 1;i <= n;++i){
        int tmp = -1;
        int x;scanf("%d",&x);
        if(x >= 6) tmp = 6;
        if(x >= 28) tmp = 28;
        if(x >= 496) tmp = 496;
        if(x >= 8128) tmp = 8128;
        res[i] = tmp;
    }
    for(int i = 1;i <= n;++i) printf("%d\n", res[i]);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值