HDOJ1085

Holding Bin-Laden Captive!

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


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


题意:输入分别有多少个1、2、5,找x系数为0时,对应的最小指数。

G(x)=(1+x+x^2+..)(1+x^2...)(1+x^5+..)  由3个表达式构成,直接展开求解即可。


之前c1[1000]开小了,导致一直显示超时,其实不是超时的原因。如果你前面几个测试用例算的都是正确的,然后后面的算了半天还没算出结果就已经超过规定时间了,但其实就算再给你时间你算出来也是错的   这样的情形下,也是Time Limit Exceeded

再比如,你前面的测试用例算出来都是正确,后面的某个测试用例输入后你就死循环了,把时间全都耗光在某一个测试用例里了,那么你也是超时(Time Limit Exceeded),但实际上你的算法还是错的,给你无限的时间你也算不出结果

#include<stdio.h> 
using namespace std;


int c1[10000],c2[10000];
int main(void)
{
	int a,b,c;

	while (scanf("%d %d %d",&a,&b,&c)!=EOF&&(a||b||c))
	{
		 int _max=a+2*b+5*c;
		for(int i=0;i<=_max;i++)
		{
			c1[i]=0;
			c2[i]=0;
		}
		for(int i=0;i<=a;i++)//第一个表达式 
		{
			c1[i]=1;
		}
		for(int j=0;j<=a;j++)  //第一项乘第二项 
		{
			for(int k=0;k<=b*2;k+=2)
			{
				c2[j+k]+=c1[j];
			}
			
					
		}
		for(int q=0;q<=a+2*b;q++)//归并同类项 
		{
				c1[q]=c2[q];
				c2[q]=0;
		}
		
		
		for(int j=0;j<=a+2*b;j++)  //接着乘第三项 
		{
			for(int k=0;k<=c*5;k+=5)
			{
				c2[j+k]+=c1[j];
			}
			
					
		}
		for(int q=0;q<=_max ;q++)//归并同类项 
		{
				c1[q]=c2[q];
				c2[q]=0;
	
		}
		int i;
 
        for(i=0; i<=_max; ++i)
            if(c1[i] == 0)
            {
                printf("%d\n", i);
                break;
            }
        if(i == _max+1)
            printf("%d\n", i);

		
	}
	return 0;
}


资源下载链接为: https://pan.quark.cn/s/1bfadf00ae14 “STC单片机电压测量”是一个以STC系列单片机为基础的电压检测应用案例,它涵盖了硬件电路设计、软件编程以及数据处理等核心知识点。STC单片机凭借其低功耗、高性价比和丰富的I/O接口,在电子工程领域得到了广泛应用。 STC是Specialized Technology Corporation的缩写,该公司的单片机基于8051内核,具备内部振荡器、高速运算能力、ISP(在系统编程)和IAP(在应用编程)功能,非常适合用于各种嵌入式控制系统。 在源代码方面,“浅雪”风格的代码通常简洁易懂,非常适合初学者学习。其中,“main.c”文件是程序的入口,包含了电压测量的核心逻辑;“STARTUP.A51”是启动代码,负责初始化单片机的硬件环境;“电压测量_uvopt.bak”和“电压测量_uvproj.bak”可能是Keil编译器的配置文件备份,用于设置编译选项和项目配置。 对于3S锂电池电压测量,3S锂电池由三节锂离子电池串联而成,标称电压为11.1V。测量时需要考虑电池的串联特性,通过分压电路将高电压转换为单片机可接受的范围,并实时监控,防止过充或过放,以确保电池的安全和寿命。 在电压测量电路设计中,“电压测量.lnp”文件可能包含电路布局信息,而“.hex”文件是编译后的机器码,用于烧录到单片机中。电路中通常会使用ADC(模拟数字转换器)将模拟电压信号转换为数字信号供单片机处理。 在软件编程方面,“StringData.h”文件可能包含程序中使用的字符串常量和数据结构定义。处理电压数据时,可能涉及浮点数运算,需要了解STC单片机对浮点数的支持情况,以及如何高效地存储和显示电压值。 用户界面方面,“电压测量.uvgui.kidd”可能是用户界面的配置文件,用于显示测量结果。在嵌入式系统中,用
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值