hdu acm 第1592题哪里错了?代码如下,错误是 runtime error

平淡平凡2022-10-04 11:39:541条回答

hdu acm 第1592题哪里错了?代码如下,错误是 runtime error
Problem Description
Gardon bought many many chocolates from the A Chocolate Market (ACM).When he was on the way to meet Angel,he met Speakless by accident.
"Ah,so many delicious chocolates!I'll get half of them and a half!" Speakless said.
Gardon went on his way,but soon he met YZG1984 by accident.
"Ah,so many delicious chocolates!I'll get half of them and a half!" YZG1984 said.
Gardon went on his way,but soon he met Doramon by accident.
"Ah,so many delicious chocolates!I'll get half of them and a half!" Doramon said.
Gardon went on his way,but soon he met JGShining by accident.
"Ah,so many delicious chocolates!I'll get half of them and a half!" JGShining said.
.
.
.
After had had met N people ,Gardon finally met Angel.He gave her half of the rest and a half,then Gardon have none for himself.Could you tell how many chocolates did he bought from ACM?
Input
Input contains many test cases.
Each case have a integer N,represents the number of people Gardon met except Angel.N will never exceed 1000;
Output
For every N inputed,tell how many chocolates Gardon had at first.
Sample Input
2
Sample Output
7
题目分析可知是2的(n+1)次方减去1;
#include
int f[1001][1001];
void add(int k)
{
int i;
for(i=0;i

已提交,审核后显示!提交回复

共1条回复
chenwei9710 共回答了24个问题 | 采纳率87.5%
额,如果已经知道答案是2的(n+1)次方减一了的话,你为什么不直接include然后调用pow(2.0,n+1)函数,得出结果再减一不就行了?
1年前

相关推荐

HDU ACM 2232一天四个不同的机器人a、b、c和d在一张跳舞毯上跳舞,这是一张特殊的跳舞毯,他由4个正方形毯子组
HDU ACM 2232
一天四个不同的机器人a、b、c和d在一张跳舞毯上跳舞,这是一张特殊的跳舞毯,他由4个正方形毯子组成一个大的正方形毯子,一开始四个机器人分别站在4块毯子上,舞蹈的每一步机器人可以往临近(两个毯子拥有同一条边视为临近)的一个毯子移动或停留在原来的毯子(同一块毯子可以有多个机器人停留),这个时候机器人的制造者你想知道经过n步的移动有多少种方式可以让每个毯子上都有机器人停留。 问一下详细的解题思路和方法
秋风抱抱1年前1
kelvinbing 共回答了25个问题 | 采纳率92%
可以用一个四位的五进制表示每块毯上有多少个机器人
把这个四位四进制压缩成一个数j
dp[i][j]代表走了i步之后四块毯上人的状态上j的情况有多少种
最后dp[n][1*5*5*5+1*5*5+1*5+1]就是答案
复杂度100*5的4次方*5的4次方
此题还可以扩展,比如步数N=MOD)path[state][j]-=MOD;
return ;
}
for(i=0;i
hdu acm 难度分布问题杭州科技大学acm题目的难度分布是怎么样的越往后越难吗 还是?改正:是杭州电子科技大学
lulu131年前1
eugene_lin 共回答了15个问题 | 采纳率93.3%
基本上不是越往后越难.
他们往里面加题应该是成套成套的加的,一般一次比赛的一套题中有十道题.加题时序号就自动增长了.
还有要看每道题的难度,可以先往下看一下这道题下面的Source,看这道题在同一次比赛中的位置,在同一次比赛中一般是越往后越难.
还有就是看通过率了,当然是通过率低的比较难.