Mourning for the victims of the 512 Wenchuan earthquake-time limit: 1000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 2328 accepted submission (s): 1157
Problem description mom
Don't cry
Tears cannot shine
Our path
Let ourselves
Go slowly
Mom
I will remember what you and dad look like.
Remember our conventions
Next Generation
This poem was excerpted from a poet's work to commemorate the victims. There is no gorgeous language, but every reader should be able to feel the strong love conveyed by the work, and there may be some helplessness. Indeed, too many unfortunate reports on children impact each of us. As Premier Wen Jiabao said, "how difficult it is to be." This disaster has brought many of our young people after 80 to maturity. Many of them have stepped onto the front line of earthquake relief as volunteers.
Today, there are n volunteers in the disaster recovery area. The earthquake relief headquarters needs to divide them into several groups. The number of groups is unlimited, but each group must have a prime number, how many grouping methods are available?
Note:
1. There can be only one group;
2. The grouping method is only related to the number of people, but not specific personnel, that is, you can assume that there is no difference between people.
Input data first contains a positive integer c, indicating that there is a group C test case, followed by row C data, each line contains a positive integer N (2 <= n <= 150 ), total number of volunteers.
For each group of test data, output the number of solutions in the group. Each output occupies one row.
Sample Input
3345
Sample output
112
#include <stdio.h>#include <string.h>#include <math.h>#define maxn 160int c1[maxn], c2[maxn], prime[maxn];bool isPrime(int n){int t = sqrt(n);for(int i = 2; i <= t; ++i)if(n % i == 0) return 0;return 1;}int main(){int i, id = 0, j, k, t, n;for(i = 2; i < 156; ++i)if(isPrime(i)) prime[id++] = i;for(i = 0; i < maxn; i += 2)c1[i] = 1;for(i = 1; prime[i] <= 150; ++i){for(j = 0; j <= 150; ++j)for(k = 0; k + j <= 150; k += prime[i])c2[j+k] += c1[j];for(j = 0; j <= 150; ++j){c1[j] = c2[j]; c2[j] = 0;}}scanf("%d", &t);while(t--){scanf("%d", &n);printf("%d\n", c1[n]);}return 0;}