hdu 2082
ps:get到了母函数...看了好久的模板与介绍....似懂非懂..决定要多找些题来试试...
代码:
#include "stdio.h"
#include "string.h"
int cal(int m2[]);
int main(){
int T,i,sum;
int c2[];
scanf("%d",&T);
while(T--){
for(i=;i<;i++)
scanf("%d",&c2[i]);
sum=cal(c2);
printf("%d\n",sum);
}
return ;
}
int cal(int m2[]){
int i,j,k,sum=;
int c1[],c2[];
memset(c1,,sizeof(c1));
memset(c2,,sizeof(c2)); //c1用来存结果,c2用来临时保存计算结果
//每次算好结果,就把c2的值给c1,然后再初始化c2.
c1[]=;
for(i=;i<=;i++){ //26个多项式相乘,循环26次 c1[3]代表x^3的系数
for(j=;j<=;j++){ //从0到50遍历,因为指数代表分数,每个指数都考虑一次,不管有没有
for(k=;k<=m2[i] && j+k*i<=;k++){ //注意这里m2数组里是i决定,就是外层的j无论循环几次
//都是由最外层的循环i决定的
//j代表是前面的多项式,k代表是现在被乘的多项式
//c1[j]*c[k*i] 指数相加,系数也相加,系数相加的是c[j]的系数.
c2[j+k*i]+=c1[j]; //c2[0]=1,k++,c2[1]=1,c2[3]=1,c2[4]=1...
//j=1,c2[1]=c1[1]=1,c2[1+1]=c2[2],c2[2]+=c1[2] c2[2]=c2[2]+0...
//c2[50]+=c1[50]
}
}
for(j=;j<=;j++){
c1[j]=c2[j];
c2[j]=;
}
}
for(i=;i<=;i++){
sum+=c1[i];
}
return sum;
}
hdu 2082的更多相关文章
- hdu 2082 生成函数
主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2082 找单词 Time Limit: 1000/1000 MS (Java/Others) Me ...
- HDU 2082 找单词 (普通型 数量有限 母函数)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2082 找单词 Time Limit: 1000/1000 MS (Java/Others) Me ...
- HDU 2082 找单词 (多重背包)
题意:假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26.那么,对于给定的字母,可以找到多少价值<=50的 ...
- 组合数学 - 母函数的运用 + 模板 --- hdu : 2082
找单词 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- HDU 2082 母函数模板题
找单词 Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Submit Status De ...
- HDU 2082 找单词
Problem Description 假 设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26.那么,对于给定的字 ...
- HDU 2082 找单词 (普通母函数)
题目链接 Problem Description 假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26.那么,对于 ...
- HDU 1028 整数拆分 HDU 2082 找单词 母函数
生成函数(母函数) 母函数又称生成函数.定义是给出序列:a0,a1,a2,...ak,...an, 那么函数G(x)=a0+a1*x+a2*x2+....+ak*xk +...+an* xn 称为序 ...
- HDU 2082 找单词 --生成函数
跟上题是一个思路:http://www.cnblogs.com/whatbeg/p/3728545.html 只不过是上一题的扩展. 代码: #include <iostream> #in ...
随机推荐
- html+asp.net上传文件
type="file" 的name以及id一定要写,并且名字相同 http://niunan.iteye.com/blog/479605 <form id="for ...
- CentOS中输入yum报错:sudo: unable to execute /bin/yum: No such file or directory
今天尝试更新了下虚拟机CentOS中的python版本后. 运行“yum”命令,就报错:“sudo: unable to execute /bin/yum: No such file or direc ...
- jquery学习笔记1
(1) jQuery的Id选择器: $("#btnShow") (2) 事件绑定函数 bind() $("#btnAdd").bind("click& ...
- 通过Sql语句导数据
在通过SQL Server向导中的SQL语句导数据时,默认情况下源表中的nvarchar字段类型会变成202,解决此问题的方法是,要重新选择一下对应的数据接收表.
- 笔记11:GDI 制作数字验证码
大二学长让我学下GDI绘制验证码,然后自己就试了试了.找了点视频看了下. 现在会画直线,矩形,字符串,制作验证码 一.绘制一条直线 private void button1_Click(object ...
- Mybatis 学习-3
1.设计Dao接口 public interface UserDao { public boolean addUser(User user); } public interface CategoryD ...
- poj-------------(2752)Seek the Name, Seek the Fame(kmp)
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11831 Ac ...
- 218. The Skyline Problem *HARD* -- 矩形重叠
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- java.lang.ClassNotFoundException: org.apache.http.util.Args
java.lang.ClassNotFoundException: org.apache.http.util.Args at org.apache.catalina.loader.WebappClas ...
- Ansible :一个配置管理和IT自动化工具
编译文章:LCTT https://linux.cn/article-4215-1.html 译者: felixonmars 文章地址:https://linux.cn/article-4215-1 ...