Gym - 102448E Everybody loves acai (打表)

    技术2024-05-07  95

    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]); }
    Processed: 0.023, SQL: 9