CCPC L(水)
2015-10-30 13:19
330 查看
Huatuo's Medicine
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)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.
Aand
B, he will put
Ainto one bottle and put
Binto 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
Aand 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.
Input
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.Output
For each test case, output one line containingCase #x: y, where x is the test case number (starting from 1) and y is the minimal number of bottles Huatuo needed.
Sample input and output
Sample Input | Sample Output |
---|---|
1 2 | Case #1 |
代码:
#include<stdio.h> int main(){ int T,N,flot=0; scanf("%d",&T); while(T--){ scanf("%d",&N); printf("Case #%d: %d\n",++flot,2*N-1); } return 0; }
相关文章推荐
- 代码大全-研究需求分析的重要性
- c语言中的结构体和共用体
- android开发笔记:常用权限说明
- LINQ(集成化查询)
- LINQ(集成化查询)
- Qt QGraphics 地图浏览 程序
- 8.7 8.8 Permutation
- 在ubuntu下访问win的共享文件夹的方法
- 【JAVA的三大循环】(1)
- yaf windows安装
- oracle 中要查询某天数据 to_date(createdt,'yyyy-MM-dd')=to_date('2010-11-25','yyyy-MM-dd'); 用这种语
- Java 数据结构学习 之 二叉树及相关
- NGINX引入线程池 性能提升9倍
- poj 1251 Jungle Roads 最小生成树
- 【maven】eclipse中maven构建web app插件冲突问题
- hdu 1171 Big Event in HDU
- python 类成员的访问权限
- Linux下C语言编译基础及makefile的编写
- overload与override的区别
- JavaScript js无间断滚动效果 scrollLeft方法 使用模板