Find the wordsTime
limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 5024 Accepted Submission (s): 3575
Problem description assumes X1 letter A, X2 letter B,..... x26 Letter Z, assuming the value of the letter A is 1 and the value of the letter B is 2,..... The value of the letter Z is 26. So, for a given letter, how much value can you find in <=50 words? The value of a word is the sum of the values of all the letters that make up a word, for example, the value of the word ACM is 1+3+14=18, and the value of the word hdu is 8+4+21=33. (The composed word is not related to the order, such as ACM and CMA think of the same word).
Input inputs are first an integer n, which represents the number of test instances.
It then includes n rows of data, each of which consists of 26 <=20 integer x1,x2,..... x26.
Output for each test instance, outputs the number of words that can be found for the total value of <=50, with one row for each instance output.
Sample Input
21 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 09 2 6 2 10 2 2 5 6 1 0 2 7 0 2 2 7 5 10 6 10 2 10 6 1 9
Sample Output
7379297
SOURCE2006/1/15 ACM Program Design Final Exam
Recommendlcy | We have carefully selected several similar problems for you:2079 1171 2152 2110 2189
Almost mother function bare question ~
#include <stdio.h> #include <string.h> #include <algorithm>using namespace Std;int num[10000];int v[ 10000];int c1[10000];int c2[10000];int generation (int Max) {memset (c1,0,sizeof (C1)); memset (c2,0,sizeof (C2)); for (int i=0;i<=num[0];i++) {c1[i]=1;} for (int i=1;i<26;i++) {for (int. j=0;j<=max;j++) {for (int k=0;k+j<=max&&k<=num[i]*v[i];k+=v[i]) {/ /k cannot be greater than num[i]*v[i]c2[j+k]+=c1[j];}} for (int j=0;j<=max;j++) {c1[j]=c2[j];c2[j]=0;}} return C1[max];} int main () {int t;scanf ("%d", &t), for (int i=0;i<26;i++) {v[i]=i+1;} while (t--) {int max=0;for (int i=0;i<26;i++) {scanf ("%d", &num[i]);} int sum=0;for (int i=1;i<=50;i++) {sum+=generation (i);} printf ("%d\n", sum);} return 0;}
Copyright NOTICE: This article is the original blogger articles, reproduced please indicate the source.
Hdoj Find the word 2082 "female function"