Problem solution: A

A
(a.pas / C / CPP)
[Title] Description
, for a given a positive integer n, determines whether the number n can be divided into a sum of positive integers (may be repeated),
each of which can be expressed as a positive integer two prime number multiplication.
[Input Description
The first line a positive integer q, the number of groups represented interrogation.
Next q lines each a positive integer n, the inquiry.
Description [output]
q lines, each a positive integer, 0 or 1.0 can not be expressed, can be represented by 1.
[Sample] input
. 5
. 1
4
. 5
21 is
25
[output] Sample
0
. 1
0
. 1
. 1
[explain] Sample
4 = 2 * 2
21 = 15 + 6 = 2 * 3 + 3 * 5
25 = 6 + 9 + 10 = 2 * 3 + 3 * 3 + 2 * 5
25 = 4 + 4 + 4 + 4 + 9 = 2 * 2 + 2 * 2 + 2 * 2 + 2 * 2 + 3 *
[data range]
30% the data satisfies: Q <= 20 is, n-<= 20 is
60% of the data satisfies: Q <= 10000, n-<5000 =
100% of the data satisfies: q <= 10 ^ 5, n <= 10 ^ 18

solution:

Because P'OK ', 4'OK', so the 'P + 4'OK

#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

int q;
LL n;

int rd(){
    int re=0,f=1;char c=getchar();
    while ((c<'0')||(c>'9')) {if (c=='-') f=-f;c=getchar();}
    while ((c>='0')&&(c<='9')) {re=re*10+c-'0';c=getchar();}
    return re*f;
}

int main(){
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    scanf("%d",&q);
    for (;q>0;--q){
        scanf("%lld",&n);
        if ((n>3ll)&&(n!=5ll)&&(n!=7ll)&&(n!=11ll)) puts("1");else puts("0");
    }
    return 0;
}

Guess you like

Origin www.cnblogs.com/skkyk/p/11685593.html