HDOJ/HDU 1085 母函数 Holding Bin-Laden Captive!

2023-05-16

Holding Bin-Laden Captive!

Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6600Accepted Submission(s): 2894


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 hides in a cave of Hang Zhou, he dares not to go out. Laden is so bored recent years that he fling himself into some math problems, and he said that if anyone can solve his problem, he will give himself up!
Ha-ha! Obviously, Laden is too proud of his intelligence! But, what is his problem?
“Given some Chinese Coins (硬币) (three kinds-- 1, 2, 5), and their number is num_1, num_2 and num_5 respectively, please output the minimum value that you cannot pay with given coins.”
You, super ACMer, should solve the problem easily, and don’t forget to take $25000000 from Bush!

Input
Input contains multiple test cases. Each test case contains 3 positive integers num_1, num_2 and num_5 (0<=num_i<=1000). A test case containing 0 0 0 terminates the input and this test case is not to be processed.

Output
Output the minimum positive value that one cannot pay with given coins, one line for one case.

Sample Input

  
1 1 3 0 0 0

Sample Output

  
4
这个题我们仍然模拟多项式乘法。最后计算就是了。
我的代码:
#include<stdio.h> #include<stdlib.h> int c1[10000]; int c2[10000]; int main() { int i,j,num1,num2,num3,sum; while(scanf("%d%d%d",&num1,&num2,&num3)!=EOF) { if(num1==0&&num2==0&&num3==0) break; sum=num1+2*num2+5*num3; for(i=0;i<=sum;i++) { c1[i]=0; c2[i]=0; } for(i=0;i<=num1;i++) c1[i]=1; for(i=0;i<=num1;i++) for(j=0;j<=2*num2;j=j+2) c2[i+j]=c2[i+j]+c1[i]; for(i=0;i<=num1+2*num2;i++) { c1[i]=c2[i]; c2[i]=0; } for(i=0;i<=num1+2*num2;i++) for(j=0;j<=5*num3;j=j+5) c2[i+j]=c2[i+j]+c1[i]; for(i=0;i<=sum;i++) { c1[i]=c2[i]; c2[i]=0; } bool flag=true; for(i=1;i<=sum;i++) if(c1[i]==0) { flag=false; printf("%d\n",i); break; } if(flag) printf("%d\n",sum+1); } return 0; }

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

HDOJ/HDU 1085 母函数 Holding Bin-Laden Captive! 的相关文章

  • /usr/bin/xauth: file /.../.Xauthority does not exist

    继我这篇博客解决了x11forwarding问题 xff0c 安装了xorg x11 xauth后 xff0c 又出现了新问题 xff0c Xauthority does not exist xff0c 真是够了 https blog cs
  • /usr/bin/ssh-copy-id: ERROR

    搭建hadoop的时候不小心配错域名 导致配置免密码登陆的时候密码一直输入错误 重新修改域名后在配置就一直报错 解决办法 在 ssh目录下修改known hosts文件中配置错的域名 直接删除 重新执行命令 ssh copy id slav
  • HDOJ 1106 排序

    题目地址 xff1a http acm hdu edu cn showproblem php pid 61 1106 Problem xff1a 输入一行数字 xff0c 如果我们把这行数字中的 5 都看成空格 xff0c 那么就得到一行用
  • /usr/bin/ld: warning: libopencv_imgcodecs.so.3.2, needed by /usr/lib/x86_64-linux-gnu/libopencv_high

    出现一个警告信息 xff0c 暂时不管 usr bin ld warning libopencv imgcodecs so 3 2 needed by usr lib x86 64 linux gnu libopencv highgui s
  • hdu1799(用递推公式求组合的个数)

    题目意思 我们知道 在编程中 我们时常需要考虑到时间复杂度 特别是对于循环的部分 例如 如果代码中出现 for i 1 i lt n i OP 那么做了n次OP运算 如果代码中出现 fori 1 i lt n i for j i 1 j l
  • hdu 1074 Doing Homework

    Problem acm hdu edu cn showproblem php pid 1074 题意 n 份作业 分别给出名字 完成所需时间 cost 最迟上交时间 deadline 作业每迟交一天扣一分 问最少的扣分数 Analysis
  • hdu 1028 Ignatius and the Princess III

    Problem acm split hdu edu cn showproblem php pid 1028 Reference 母函数 Generating function 详解 TankyWoo ACM 母函数专题 Meaning 将一
  • hdu 6069 Counting Divisors

    Problem acm hdu edu cn showproblem php pid 6069 Meaning 定义函数d n n 的因子个数 给定区间 l r 和常数 k 求 i lrd ik mod 998244353 sum r i
  • hdu 6127 Hard challenge

    Problem acm hdu edu cn showproblem php pid 6127 Meaning 平面上有 n 个不重合的点 任意三点不共线 任意两点所在直线不经原点 每个点有个 value 任意两个点连出的线段的 value
  • hdu 1024 Max Sum Plus Plus

    Problem acm hdu edu cn showproblem php pid 1024 题意 给一个长为 n 的序列 有从中挑 m 个相互不重合的子序列求总和 让总和最大 分析 没能看懂百度的前几份题解 好像都跟 kuangbin
  • hdu 1438 钥匙计数之一

    Problem acm hdu edu cn showproblem php pid 1438 Reference blog csdn net u010405898 article details 9530769 blog csdn net
  • hdu 4405 Aeroplane chess

    Problem acm hdu edu cn showproblem php pid 4405 vjudge net contest 151678 problem R Reference bbs csdn net topics 380193
  • hdu 1069 Monkey and Banana

    Problem acm hdu edu cn showproblem php pid 1069 Reference www cnblogs com kuangbin archive 2011 08 04 2127291 html 题意 给
  • hdu 5818 Joint Stacks 2016 Multi-University 7

    Problem acm hdu edu cn showproblem php pid 5818 官方题解 bestcoder hdu edu cn blog 2016 multi university training contest 7
  • hdu 4712 Hamming Distance

    Problem acm hdu edu cn showproblem php pid 4712 Reference 多向 bfs 思路 CSDN markdown 用 LaTeX Meaning 定义两个整数数 a 和 b 的汉明距离为 a
  • Keil不能正确生成.bin文件的解决办法

    1 打开keil IDE 然后打开help gt uVison Help 搜索fromelf关键字如下图1 然后再进入到右下角的索引找到fromelf命令行的语法和选项 找到 bin的说明如下 如红色标注所说 正是症结所在 即如果链接文件中
  • hdu 2586 How far away ?

    Problem acm hdu edu cn showproblem php pid 2586 Meaning 给一棵 n 个点的树 和 n 1 条边的边权 多次询问树上两点的距离 Analysis 以任意顶点为根 DFS 预处理出所有结点
  • hdu 5792 World is Exploding 2016 Multi-University 5

    Problem acm hdu edu cn showproblem php pid 5792 题意 给一个序列 V 问有多少个由下标组成的四元组 a b c d 满足 a b c d a lt b c lt d Va lt Vb Vc g
  • 如何直接在 C# 中执行批处理命令?

    我想执行批处理命令并将输出保存在字符串中 但我只能执行文件而无法将内容保存在字符串中 批处理文件 回声关闭 C lmxendutil exe licstatxml 主机 serv005 端口 6200 gt C Temp HW Lic XM
  • Android APK 文件和 DEX 文件未创建,没有警告或错误

    我开发Android已经有一段时间了 使用WIN7 64位和Eclipse 由于我尝试安装新的 ADT 1 5 我遇到了一个非常奇怪的现象 我的构建未完成 并且未生成 APK 文件 也未生成 dex 文件 类文件已创建 但没有其他任何内容

随机推荐