题目链接:https://vjudge.net/problem/HDU-2082

题意:中文题。

思路:构造普通母函数求解。

母函数:

  1 #include<time.h>
2 #include <set>
3 #include <map>
4 #include <stack>
5 #include <cmath>
6 #include <queue>
7 #include <cstdio>
8 #include <string>
9 #include <vector>
10 #include <cstring>
11 #include <utility>
12 #include <cstring>
13 #include <iostream>
14 #include <algorithm>
15 #include <list>
16 using namespace std;
17 #define eps 1e-10
18 #define PI acos(-1.0)
19 #define lowbit(x) ((x)&(-x))
20 #define zero(x) (((x)>0?(x):-(x))<eps)
21 #define mem(s,n) memset(s,n,sizeof s);
22 #define ios {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
23 typedef long long ll;
24 typedef unsigned long long ull;
25 const int maxn=1e5+5;
26 const int Inf=0x7f7f7f7f;
27 const ll Mod=1e9+7;
28 //const int N=3e3+5;
29 bool isPowerOfTwo(int n) { return n > 0 && (n & (n - 1)) == 0; }//判断一个数是不是 2 的正整数次幂
30 int modPowerOfTwo(int x, int mod) { return x & (mod - 1); }//对 2 的非负整数次幂取模
31 int getBit(int a, int b) { return (a >> b) & 1; }// 获取 a 的第 b 位,最低位编号为 0
32 int Max(int a, int b) { return b & ((a - b) >> 31) | a & (~(a - b) >> 31); }// 如果 a>=b,(a-b)>>31 为 0,否则为 -1
33 int Min(int a, int b) { return a & ((a - b) >> 31) | b & (~(a - b) >> 31); }
34 ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
35 ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
36 int Abs(int n) {
37 return (n ^ (n >> 31)) - (n >> 31);
38 /* n>>31 取得 n 的符号,若 n 为正数,n>>31 等于 0,若 n 为负数,n>>31 等于 -1
39 若 n 为正数 n^0=n, 数不变,若 n 为负数有 n^(-1)
40 需要计算 n 和 -1 的补码,然后进行异或运算,
41 结果 n 变号并且为 n 的绝对值减 1,再减去 -1 就是绝对值 */
42 }
43 ll binpow(ll a, ll b,ll c) {
44 ll res = 1;
45 while (b > 0) {
46 if (b & 1) res = res * a%c;
47 a = a * a%c;
48 b >>= 1;
49 }
50 return res%c;
51 }
52 void extend_gcd(ll a,ll b,ll &x,ll &y)
53 {
54 if(b==0) {
55 x=1,y=0;
56 return;
57 }
58 extend_gcd(b,a%b,x,y);
59 ll tmp=x;
60 x=y;
61 y=tmp-(a/b)*y;
62 }
63 ll mod_inverse(ll a,ll m)
64 {
65 ll x,y;
66 extend_gcd(a,m,x,y);
67 return (m+x%m)%m;
68 }
69 ll eulor(ll x)
70 {
71 ll cnt=x;
72 ll ma=sqrt(x);
73 for(int i=2;i<=ma;i++)
74 {
75 if(x%i==0) cnt=cnt/i*(i-1);
76 while(x%i==0) x/=i;
77 }
78 if(x>1) cnt=cnt/x*(x-1);
79 return cnt;
80 }
81 ll c1[55],c2[55];
82 int main()
83 {
84 int t;
85 cin>>t;
86 while(t--)
87 {
88 mem(c1,0);
89 mem(c2,0);
90 c1[0]=1;
91 int x;
92 for(int i=1;i<=26;i++)
93 {
94 scanf("%d",&x);
95 for(int j=0;j<=50;j++)
96 {
97 for(int k=0;k<=x&&(j+k*i)<=50;k++)
98 {
99 c2[j+i*k]+=c1[j];
100 }
101 }
102 for(int j=0;j<=50;j++)
103 {
104 c1[j]=c2[j];
105 c2[j]=0;
106 }
107 }
108 ll ans=0;
109 for(int i=1;i<=50;i++) ans+=c1[i];
110 cout<<ans<<endl;
111 }
112 return 0;
113 }

找单词 HDU - 2082(普通母函数)的更多相关文章

  1. HDU 2082 普通型母函数

    分析: 组成单词好说,价值如何体现? 改变指数就行,例如: 这样,组成的单词,指数就是权值,多项式相乘,指数小于50的就OK: #include <bits/stdc++.h> using ...

  2. HDU 2082 找单词 (普通型 数量有限 母函数)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2082 找单词 Time Limit: 1000/1000 MS (Java/Others)    Me ...

  3. HDU 2082 找单词 (普通母函数)

    题目链接 Problem Description 假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26.那么,对于 ...

  4. HDU 1028 整数拆分 HDU 2082 找单词 母函数

    生成函数(母函数) 母函数又称生成函数.定义是给出序列:a0,a1,a2,...ak,...an, 那么函数G(x)=a0+a1*x+a2*x2+....+ak*xk +...+an* xn  称为序 ...

  5. hdu acm 2082 找单词

    找单词 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  6. HDU——2083找单词(母函数)

    找单词 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submissio ...

  7. HDOJ 2082 找单词 (母函数)

    找单词 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  8. HDU 2082 找单词 (多重背包)

    题意:假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26.那么,对于给定的字母,可以找到多少价值<=50的 ...

  9. HDU 2082 找单词

    Problem Description 假 设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26.那么,对于给定的字 ...

随机推荐

  1. HDU 4272 LianLianKan(状压DP)题解

    题意:一个栈,每次可以选择和栈顶一样的数字,并且和栈顶距离小于6,然后同时消去他们,问能不能把所有的数消去 思路:一个数字最远能消去和他相距9的数,因为中间4个可以被他上面的消去.因为还要判断栈顶有没 ...

  2. Angular 2 for 2017 web full stack development

    1 1 1 Angular 2 for 2017 web full stack development 1 1 https://angular2.xgqfrms.xyz/ https://ng2-he ...

  3. ThoughtWorks Homework

    ThoughtWorks Homework Homework 考察知识点 项目搭建 技术选型 测试 编码风格 代码质量 设计模式 数据结构 算法 架构 开源协作 CI/CD DevOps Linux ...

  4. WEB 硬件设备联网

    在js中与第三方设备的通信 这是一个Xbox One手柄的demo,将手柄使用USB连接到PC上: See also: video Device APIs 通过JavaScript与蓝牙设备通信 在网 ...

  5. C++算法代码——阿克曼函数

    题目来自: 题目描述 阿克曼( Ackmann) 函数 A(x, y) 中, x, y 定义域是非负整数, 函数值定义为: 输入 输入两个数,表示m和n. 两个数均不超过10. 输出 输出一个数,表示 ...

  6. 处理ios键盘弹出按钮点击click失效

    用ontouchstart绑定事件即可,然后用 document.activeElement.blur();让键盘收起 this.value = value.replace(/\s/g, " ...

  7. winform捕捉全局异常

    /// <summary> /// 应用程序的主入口点. /// </summary> [STAThread] static void Main() { try { //设置应 ...

  8. Python网络编程相关的库与爬虫基础

    PythonWeb编程 ①相关的库:urlib.urlib2.requests python中自带urlib和urlib2,他们主要使用函数如下: urllib: urlib.urlopen() ur ...

  9. vscode undefined reference to `_imp__WSAStartup@8

    vscode undefined reference to `_imp__WSAStartup@8' 使用vscode和g++编译.cpp时,报出如题错误,如下图: 查了百度之后,在.vscode/t ...

  10. 干货!!!测试如何确定是前端bug还是后端bug

    目前的项目大多数都是前后端分离的,当我们发现bug后不知道指派给哪位开发,指派错了不仅影响解决bug 的效率,还容易被开发怼.最主要的是人家会认为你不专业,不专,不专呀.废话少说,上干货(踩过的坑)! ...