HDOJ 5551 Huatuo's Medicine (水)
2015-11-02 21:47
393 查看
Huatuo's Medicine
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 28 Accepted Submission(s): 20
[align=left]Problem Description[/align]
Huatuo was a famous doctor. He use identical bottles to carry the medicine. There are different types of medicine. Huatuo put medicines into the bottles and chain these bottles together.
However, there was a critical problem. When Huatuo arrived the patient's home, he took the chain out of his bag, and he could not recognize which bottle contains which type of medicine, but he remembers the order of the bottles on the chain.
Huatuo has his own solution to resolve this problem. When he need to bring 2 types of medicines, E.g.
A
and B,
he will put A
into one bottle and put B
into two bottles. Then he will chain the bottles in the order of
′−B−A−B−′.
In this way, when he arrived the patient's home, he knew that the bottle in the middle is medicine
A
and the bottle on two sides are medicine B.
Now you need to help Huatuo to work out what's the minimal number of bottles needed if he want to bring
N
types of medicine.
[align=left]Input[/align]
The first line of the input gives the number of test cases,
T(1≤T≤100).
T
lines follow. Each line consist of one integer N(1≤N≤100),
the number of types of the medicine.
[align=left]Output[/align]
For each test case, output one line containing
Case #x: y, where x
is the test case number (starting from 1) and y
is the minimal number of bottles Huatuo needed.
[align=left]Sample Input[/align]
1
2
[align=left]Sample Output[/align]
Case #1: 3
ac代码:
#include<stdio.h> #include<string.h> #include<math.h> #include<iostream> #include<algorithm> #define MAXN 100100 #define MOD 1000000007 #define LL long long #define INF 0xfffffff using namespace std; int main() { int t,n; int cas=0; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("Case #%d: %d\n",++cas,2*n-1); } return 0; }
相关文章推荐
- 商业模式(二):P2P网贷平台,利差和服务费为主的金融玩法
- 商业模式(二):P2P网贷平台,利差和服务费为主的金融玩法
- 无限轮播图
- elipse启动报错:org.eclipse.swt.SWTException: Invalid thread access
- Unity Shader:Blur
- Activity的四种加载模式
- PLAYGROUND 延时运行
- hdoj 5521 Meeting 【优先队列 dijkstra】
- 语义分析的一些方法(下篇)
- 树---判断两棵树是否相等
- Codevs P1982 加密算法
- hdu1241 Oil Deposits
- [leetcode 198]House Robber
- VM VirtualBox虚拟机共享文件夹(ubuntu)
- 浅谈C#集合【转】
- 【问题解决】线程间操作无效:从不是创建控件“textBox1”的线程访问它
- U3D 背景音效和事件触发音效
- 阅读有关软件工程与计算机科学区别的文章,谈谈你的看法。
- bzoj1620【Usaco2008 Nov】Time Management 时间管理
- 玩转树莓派--网卡配置