HDOJ 1709 The Balance(母函数)】的更多相关文章

The Balance Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4497    Accepted Submission(s): 1808 Problem Description Now you are asked to measure a dose of medicine with a balance and a number o…
The Balance Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5706    Accepted Submission(s): 2311 Problem Description Now you are asked to measure a dose of medicine with a balance and a number o…
母函数,指数可以为1也可以为-1,扩大指数加消减发现TLE,于是采用绝对值就过了. #include <stdio.h> #include <string.h> #define MAXNUM 10001 int c1[MAXNUM], c2[MAXNUM]; ]; int myabs(int x) { ? -x:x; } int main() { int n, sum, tmp; int i, j, k; while (scanf("%d", &n) !…
题意: 有一个天平.有N个砝码.重量分别是A1...AN. 问重量[1..S]中有多少种重量是无法利用这个天平和这些砝码称出来的. S是N个砝码的重量总和. 思路: 对于每一个砝码来说,有三种:不放,放左盘,放右盘. 额,,母函数和DP其实核心一样,,,, 看代码,, 代码: int n; int aa[105]; bool a[10005], b[10005]; int temp[10005]; int main(){ while(scanf("%d",&n)!=EOF){…
The Balance Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7212    Accepted Submission(s): 2978 Problem Description Now you are asked to measure a dose of medicine with a balance and a number…
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1709 题意:给你一些砝码,让你输出1—sum中不能称出的重量 题解:直接上母函数,在合并括号的时候有加有减,期中mu()为我自己写的模版,所以有点冗杂 #include<cstdio> #include<cstring> ; ?a:-a;} int c1[maxn], c2[maxn],sum;//c1保存每个指数的系数,c2为中间变量 ],datanum[],allnum,ans[]…
母函数的特殊情况,左右两边都可以放,如样例1,2,9 母函数为(1+x+1/x)*(1+x^2+1/x^2)*(1+x^9+1/x^9) 化简为(1+x+x^2)*(1+x^2+x^4)*(1+x^9+x^18)/(x*x^2*x^9) 这样就好计算了,看代码: ;}…
The Balance Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5956    Accepted Submission(s): 2427 Problem Description Now you are asked to measure a dose of medicine with a balance and a number o…
Coin Change Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10289    Accepted Submission(s): 3451 Problem Description Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1…
选课时间(题目已修改,注意读题) Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2137    Accepted Submission(s): 1699 Problem Description 又到了选课的时间了,xhd看着选课表发呆,为了想让下一学期好过点,他想知道学n个学分共有多少组合.你来帮帮他吧.(xhd认为一样学分的课没区别)…
找单词 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2919    Accepted Submission(s): 2089 Problem Description 假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26.那么,对于给定的字母,可以找到…
Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6416    Accepted Submission(s): 4336 Problem Description People in Silverland use square coins. Not only they have square shapes but…
HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsum  贪心 HDU 1004 Let the Balloon Rise  字典树,map HDU 1005 Number Sequence  求数列循环节 HDU 1007 Quoit Design  最近点对 HDU 1008 Elevator  模拟 HDU 1010 Tempter of th…
The Balance Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6652    Accepted Submission(s): 2730 Problem Description Now you are asked to measure a dose of medicine with a balance and a number o…
题意: 现在你被要求用天平和一些砝码来量一剂药.当然,这并不总是可以做到的.所以你应该找出那些不能从范围[1,S]中测量出来的品质.S是所有重量的总质量. 输入一个n,后面有n个数,表示这n个物品的质量 题解: 注意这个题的题干,这个天平只要能制造出来那个质量差,然后这个质量差就不会输出(看懂第二个样例就行) 这道题是母函数的变化版,没学过母函数的可以看一下:母函数 <普通母函数(HDU - 1028 ) && 指数型母函数(hdu1521)> 代码: 1 #include&l…
题目连接:hdu_5616_Jam's balance 题意: 给你一些砝码,和一些要被称出的重量,如果这些砝码能称出来输出YES,否则输出NO 题解:我们想想,这题求组合方式,我们这里可以直接用母函数艹过去,这里我写的枚举子集的方式,其实就是母函数的形式 #include<cstdio> #define F(i,a,b) for(int i=a;i<=b;i++) ?-a:a;} ],dp[][]; int main(){ int t,n,m,sum,x; scanf("%d…
The Balance Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7677    Accepted Submission(s): 3187 Problem Description Now you are asked to measure a dose of medicine with a balance and a number o…
Problem Description We all know that Bin-Laden is a notorious terrorist, and he has disappeared for a long time. But recently, it is reported that he hides in Hang Zhou of China! "Oh, God! How terrible! " Don't be so afraid, guys. Although he hi…
题意:非常清楚不解释. 策略:如题. 就是个简单的母函数的改变. 这道题做了好久,才明确是那有毛病,还是理解的不够深刻. AC代码: #include<stdio.h> #include<string.h> int c1[155], c2[155]; int pri[150] = {3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103…
Fruit Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2432    Accepted Submission(s): 1345 Problem Description 转眼到了收获的季节,由于有TT的专业指导,Lele获得了大丰收.特别是水果,Lele一共种了N种水果,有苹果,梨子,香蕉,西瓜……不但味道好吃,样子更是好看. 于是,…
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11583    Accepted Submission(s): 5188 Problem Description We all know that Bin-Laden is a notorious terrorist, and he h…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9532    Accepted Submission(s): 6722 Problem Description "Well, it seems the first problem is too easy. I will let y…
扩展欧几里得的应用. /* 1356 */ #include <iostream> #include <sstream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <deque> #include <bitset>…
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17327    Accepted Submission(s): 7764 Problem Description We all know that Bin-Laden is a notorious terrorist, and he h…
#include<iostream>#include<cstring>using namespace std;int main(){    int c1[10000],c2[10000];    int i,j,k;    int n;    while(cin>>n)    {        memset(c1,0,sizeof(c1));        memset(c2,0,sizeof(c2));        for(i=0;i<=n;i++) c1[i…
母函数(Generating function)详解 - Tanky Woo 在数学中,某个序列的母函数(Generating function,又称生成函数)是一种形式幂级数,其每一项的系数可以提供关于这个序列的信息.使用母函数解决问题的方法称为母函数方法. 母函数可分为很多种,包括普通母函数.指数母函数.L级数.贝尔级数和狄利克雷级数.对每个序列都可以写出以上每个类型的一个母函数.构造母函数的目的一般是为了解决某个特定的问题,因此选用何种母函数视乎序列本身的特性和问题的类型. 这里先给出两句…
The Balance Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4737    Accepted Submission(s): 1895 Problem Description Now you are asked to measure a dose of medicine with a balance and a number o…
母函数(Generating function)详解 — Tanky Woo 在数学中,某个序列的母函数(Generating function,又称生成函数)是一种形式幂级数,其每一项的系数可以提供关于这个序列的信息.使用母函数解决问题的方法称为母函数方法. 母函数可分为很多种,包括普通母函数.指数母函数.L级数.贝尔级数和狄利克雷级数.对每个序列都可以写出以上每个类型的一个母函数.构造母函数的目的一般是为了解决某个特定的问题,因此选用何种母函数视乎序列本身的特性和问题的类型. 这里先给出两句…
转自:母函数 入门 + 模板  感谢 在数学中,某个序列的母函数(Generating function,又称生成函数)是一种形式幂级数,其每一项的系数可以提供关于这个序列的信息.使用母函数解决问题的方法称为母函数方法. 母函数可分为很多种,包括普通母函数.指数母函数.L级数.贝尔级数和狄利克雷级数.对每个序列都可以写出以上每个类型的一个母函数.构造母函数的目的一般是为了解决某个特定的问题,因此选用何种母函数视乎序列本身的特性和问题的类型. 这里先给出两句话,不懂的可以等看完这篇文章再回过头来看…
母函数(Generating function)详解 在数学中,某个序列的母函数(Generating function,又称生成函数)是一种形式幂级数,其每一项的系数可以提供关于这个序列的信息.使用母函数解决问题的方法称为母函数方法. 母函数可分为很多种,包括普通母函数.指数母函数.L级数.贝尔级数和狄利克雷级数.对每个序列都可以写出以上每个类型的一个母函数.构造母函数的目的一般是为了解决某个特定的问题,因此选用何种母函数视乎序列本身的特性和问题的类型. 这里先给出两句话,不懂的可以等看完这篇…