Hdoj 2189 mourns the victims of the 512 Wenchuan earthquake-coming together in the next generation [primary function]

Source: Internet
Author: User

Question: I do not explain it clearly.

Policy: for example, the question is a simple change of the master function.

It took a long time for this question to understand whether there was a problem or whether it was not profound enough.

AC code:

# Include <stdio. h> # include <string. h> int c1 [155], C2 [155]; int pri [150] = {3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 97,101,103,107,109,113,127,131,137,139,149,155, 79, 83, 89, 5}; // here, Tl once, note that the last 1555 (which can be changed to any number greater than 150) cannot be lost if it is deleted, because after 149, It is 0.int main () {int t, n; scanf ("% d", & T); While (t --) {scanf ("% d", & N); int I, j; memset (C1, 0, sizeof (C1); memset (C2, 0, sizeof (C2); for (I = 0; I <= N; I + = 2) {c1 [I] = 1 ;}for (I = 0; pri [I] <= N; I ++) {for (j = 0; j <= N; j ++) {for (int K = 0; k + j <= N; k + = pri [I]) {c2 [J + k] + = c1 [J] ;}} for (j = 0; j <= N; j ++) {c1 [J] = c2 [J]; c2 [J] = 0 ;}} printf ("% d \ n", c1 [N]) ;}}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.