程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> Holding Bin-Laden Captive!£¨º¼µç1085£©£¨Ä¸º¯Êý£©

Holding Bin-Laden Captive!£¨º¼µç1085£©£¨Ä¸º¯Êý£©

編輯:C++入門知識

Holding Bin-Laden Captive!£¨º¼µç1085£©£¨Ä¸º¯Êý£©


Holding Bin-Laden Captive!

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


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 fZ†·Ÿ"http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcmdldCB0byB0YWtlICQyNTAwMDAwMCBmcm9tIEJ1c2ghPGJyPgoKCiAKPGJyPgoKSW5wdXQKCklucHV0IGNvbnRhaW5zIG11bHRpcGxlIHRlc3QgY2FzZXMuIEVhY2ggdGVzdCBjYXNlIGNvbnRhaW5zIDMgcG9zaXRpdmUgaW50ZWdlcnMgbnVtXzEsIG51bV8yIGFuZCBudW1fNSAoMDw9bnVtX2k8PTEwMDApLiBBIHRlc3QgY2FzZSBjb250YWluaW5nIDAgMCAwIHRlcm1pbmF0ZXMgdGhlIGlucHV0IGFuZCB0aGlzIHRlc3QgY2FzZSBpcyBub3QgdG8gYmUgcHJvY2Vzc2VkLjxicj4KCgogCjxicj4KCk91dHB1dAoKT3V0cHV0IHRoZSBtaW5pbXVtIHBvc2l0aXZlIHZhbHVlIHRoYXQgb25lIGNhbm5vdCBwYXkgd2l0aCBnaXZlbiBjb2lucywgb25lIGxpbmUgZm9yIG9uZSBjYXNlLjxicj4KCgogCjxicj4KClNhbXBsZSBJbnB1dAoKPHByZSBjbGFzcz0="brush:java;">1 1 3 0 0 0
Sample Output
4
/*ĸº¯ÊýÓ¦Óᣲ»ÊÇÌ«Àí½â¡£Ä£·ÂÄ£°å£¬¼Çס´úÂë= = 
*/
#include
int a[10000],s[10000];
int main()
{
	int x,y,z,max;
	int i,j,k;
	while(scanf("%d%d%d",&x,&y,&z)&&(x||y||z))
	{
		max=x+y*2+z*5;
		for(i=0;i<=max;i++)
		{
			a[i]=0;
			s[i]=0;
		}
		for(i=0;i<=x;i++)
		    s[i]=1;
		for(i=0;i<=x;i++)
		{
			for(j=0;j<=y*2;j+=2)
			{
				a[i+j]+=s[i];
			}
		}
		for(i=0;i<=x+y*2;i++)
		{
			s[i]=a[i];
			a[i]=0;
		}
		for(i=0;i<=x+y*2;i++)
		{
			for(j=0;j<=z*5;j+=5)
			{
				a[i+j]+=s[i];
			}
		}
		for(i=0;i<=max;i++)
		{
			s[i]=a[i];
			a[i]=0;
	    }
	    for(i=0;i<=max;i++)
	    {
	    	if(s[i]==0)
	    	{
			    printf("%d\n",i);
			    break;
			}
	    }
	    if(i==max+1)
	      printf("%d\n",i);
    }
	return 0;
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved