题目链接
http://acm.hdu.edu.cn/showproblem.php?pid=5703
题意 给出一杯容量为N的水 每次至少喝1个单位 有多少种不同的方式喝完
比如 给出3 就有4种方式 0.1 1 1 1.1 2 2.2 1 3. 3
思路 其实观察几项后就可以发现,答案就是 2的n - 2 次方
由于会爆longlong 我们直接输出字符串就可以了
就是1后面(n - 1)个0
AC代码
#include<stdio.h>
int main() {
int t,i;
scanf(
"%d",&t);
while (t--) {
scanf(
"%d",&i);
printf(
"1");
i--;
while (i--)
printf(
"0");
printf(
"\n");
}
}
转载于:https://www.cnblogs.com/Dup4/p/9433099.html
相关资源:JAVA上百实例源码以及开源项目