HDU 1028 Ignatius and the Princess III
来源:互联网 发布:离线搜题软件 编辑:程序博客网 时间:2024/05/21 01:48
题目地址:点击打开链接
思路:母函数模板题,以四为例,求(1+x+x^2+x^3+x^4)(1+x^2+x^4)(1+x^3)(1+x^4)即可
AC代码:
#include <iostream>using namespace std;int main(){ int i,j,k; int c1[130],c2[130]; int n; while(cin>>n) { for(i=0; i<=n; i++) { c1[i] = 1; c2[i] = 0; } for(i=2; i<=n ;i++)//依次从第二个括号开始与前面的运算结果相乘 { for(j=0; j<=n; j++)//前面的各项结果和后面的式子相乘 { for(k=0; k+j<=n; k+=i)//控制后面每项式子的增量如,1 + x^2 + x^4 +x^6 +.....增量为2 { c2[j+k] += c1[j];//系数相加,因为后面的一个式子系数为1就不加了,如5x^2*x^2相乘后的系数为5 } } for(j=0; j<=n; j++) { c1[j] = c2[j];//重新赋值,不断重复,直到所有括号都用完 c2[j] = 0; } } cout<<c1[n]<<endl; } return 0;}
0 0
- hdu 1028 Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- HDU-1028-Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- hdu 1028 Ignatius and the Princess III
- HDU--1028 Ignatius and the Princess III
- HDU 1028 Ignatius and the Princess III
- Ignatius and the Princess III hdu 1028
- 中国版TestFlight?Testin推免费手游内测分发工具Pre.im
- 学习网站
- 解决VirtualBox下安装虚拟机(Ubuntu)出错(不能为虚拟电脑Ubuntu打开一个新的任务)的问题
- Delete Node in a Linked List
- MYSQL之表分区----按日期分区
- HDU 1028 Ignatius and the Princess III
- ruby调用shell问题——找不到自己环境变量中的程序
- javassist学习三
- CodeChef COUNTARI Arithmetic Progressions FFT + 分块
- Objective-C 属性特性详解
- APP源码分享-你最美源码
- ubuntu14.04 64位 adb配置问题
- 连接数据库报“You have an error in your SQL syntax”异常的解决
- Quarzt 2D 裁剪