hdu 2082 找单词 母函数
来源:互联网 发布:js仿今日头条导航栏 编辑:程序博客网 时间:2024/05/17 23:36
找单词
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5938 Accepted Submission(s): 4169
Problem Description
假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26。那么,对于给定的字母,可以找到多少价值<=50的单词呢?单词的价值就是组成一个单词的所有字母的价值之和,比如,单词ACM的价值是1+3+14=18,单词HDU的价值是8+4+21=33。(组成的单词与排列顺序无关,比如ACM与CMA认为是同一个单词)。
Input
输入首先是一个整数N,代表测试实例的个数。
然后包括N行数据,每行包括26个<=20的整数x1,x2,.....x26.
然后包括N行数据,每行包括26个<=20的整数x1,x2,.....x26.
Output
对于每个测试实例,请输出能找到的总价值<=50的单词数,每个实例的输出占一行。
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
Source
2006/1/15 ACM程序设计期末考试
Recommend
lcy | We have carefully selected several similar problems for you: 2079 1085 1171 1398 2152
#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<cmath>#include<algorithm>#include<vector>using namespace std;#define all(x) (x).begin(), (x).end()#define for0(a, n) for (int (a) = 0; (a) < (n); (a)++)#define for1(a, n) for (int (a) = 1; (a) <= (n); (a)++)typedef long long ll;typedef pair<int, int> pii;const int INF =0x3f3f3f3f;const int maxn= 50 ;const int N= 26 ;int a[2][maxn+10];//系数,滚动数组,母函数,void work(){ memset(a[0],0,sizeof a[0]); a[0][0]=1; int num; int now=1,nex=0;//a[now]保存计算累计的结果,a[nex]表示临时的。 for1(i,N) { now^=1; nex^=1; scanf("%d",&num); memset(a[nex],0,sizeof a[nex]); for(int add=0;add<=min(maxn,num*i);add+=i) { for(int j=maxn;j>=add;j--) { a[nex][j]+=a[now][j-add]; } } } int ans=0; for0(i,maxn+1) ans+=a[nex][i]; printf("%d\n",ans-1);//有一个是一个单词都不选}int main(){ int T;scanf("%d",&T); while(T--) { work(); } return 0;}/*231 1 1*/
0 0
- HDU 2082 找单词(母函数)
- hdu 2082 找单词(母函数)
- hdu 2082 找单词 (母函数)
- HDU 2082 找单词 (母函数)
- HDU 2082 找单词 母函数
- hdu 2082 找单词 母函数
- HDU 2082 找单词 基础母函数
- Hdu 2082 找单词 母函数
- HDU 2082 找单词(母函数)
- hdu 2082(找单词)(母函数,模板)
- HDU 2082-找单词(母函数)
- HDU 2082 找单词【母函数】
- HDU 2082 找单词 (母函数)
- HDU 2082 找单词(母函数基础)
- (母函数变形)hdu 2082 找单词
- HDU 2082 找单词(母函数)
- HDU 2082 找单词 (母函数入门)
- HDU---2082-找单词(母函数)
- Java并发编程-阻塞队列(BlockingQueue)的实现原理
- Android入门--CheckBox 的isChecked 属性
- linux下面select返回115错误
- hdu3461(并查集+快速幂)
- POJ2409 Let it Bead
- hdu 2082 找单词 母函数
- 依赖注入——人生若只如初见
- hdu 5407 CRB and Candies(数论,LCM,快速幂取模,求逆元)
- Redis基础(1)
- JavaScript 入门篇
- STM7F系列的资料
- 关于容器~
- sqoop访问MySql被拒绝
- SQL Select语句完整执行顺序