Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=2082
Title Description: 26 letters each have value, respectively, is 1 to 26, give the number of each letter, to find the word value of not more than 50 words have how many;
The subject of the same kind is for change: give several denominations of the coin each have a few, for 50 yuan to change how many kinds of law;
Main points of the topic: female function;
The parent function requires two arrays, an array to record the current kind, and an array as a temporary array to assist in determining the next few;
C1:1 0 0 0 0 0 0 0 00 ..... (Initialize)
c2:0 00000000..... (Initialize)
Three-layer cycle, the first cycle of the letter type, the second used to cycle the number of the letter; the third layer loops out the value of the letter added to different values, generating new values; array c1&c2 subscript is value, The sum of the value of the caption that is taken out is added to the corresponding C2 array with the value of the previously taken out;
The values in the two arrays hold the value represented by the corresponding subscript so far there are several ways;
The code is as follows:
1#include <stdio.h>2#include <string.h>3 4 intMain ()5 {6 intt,i,j,z;7 intans,c1[Wuyi],c2[Wuyi],ab[ -];8scanf"%d",&T);9 while(t--)Ten { One for(i=1; i<= -; i++) A { -scanf"%d",&ab[i]); - } thememset (C1,0,sizeof(C1)); -memset (C2,0,sizeof(C2)); -c1[0]=1; - for(i=1; i<= -; i++) + { - for(j=1; j<=ab[i];j++) + { A for(z=0;z<Wuyi; z++) at { - if(z+i*j> -)//if the value is greater than 50, there is no need to consider it; - Break; -C2[Z+J*I]+=C1[Z];//The number of species is stored in the C1, and the number of the original species is added to the number of new species, and the total category is obtained . - } - } in for(j=1;j<Wuyi; j + +) - { toC1[J]+=C2[J];//Add the number of categories in the C2 back to the C1 array; + } -memset (C2,0,sizeof(C2));//C2 array clear 0; the } *ans=0; $ for(i=1;i<Wuyi; i++)Panax Notoginseng { -ans+=C1[i]; the } +printf"%d\n", ans); A } the return 0; +}
View Code
hdoj--2082< Parent Function >