早教吧作业答案频道 -->英语-->
hduacm第1592题哪里错了?代码如下,错误是runtimeerrorProblemDescriptionGardonboughtmanymanychocolatesfromtheAChocolateMarket(ACM).WhenhewasonthewaytomeetAngel,hemetSpeaklessbyaccident."Ah,somanydeliciouschocola
题目详情
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
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
▼优质解答
答案和解析
额,如果已经知道答案是2的(n+1)次方减一了的话,你为什么不直接include然后调用pow(2.0,n+1)函数,得出结果再减一不就行了?
看了 hduacm第1592题哪里...的网友还看了以下:
某人 在一以2.5m每平方秒的加速度匀加速下降的电梯里最多能举起80千克的物体,在地面上最多能举起 2020-05-16 …
急,理工题!如下补充!已知A={t|使得{x|x^2+2tx-4t-3≠0}=R},B={t|使得 2020-06-06 …
当物体失重时,F=m(g-a),a有可能大于g吗?为什么比如说一人在半空中,给他施一个力F,F=m 2020-06-24 …
当物体失重时,F=m(g-a),a有可能大于g吗?为什么 2020-06-24 …
2道简单的机械能题!1.起重机吊钩下挂着质量为m的木箱,如果木箱以加速度a匀减速下降了高度h,则木箱 2020-11-22 …
m(g+a)=0时是完全失重,但m(g+a) 2020-12-01 …
失重中a和g的问题失重最后力的计算公式是F=m(g-a)g,最后计算的值变为负值,那么会出现什么物理 2020-12-02 …
如果单从理论上讲.物体挂在弹簧秤上,二者一起做减速运动,此时有mg-T=ma,所以拉力T=mg-ma 2020-12-02 …
如图所示,有一辆汽车满载西瓜在水平路面上匀速前进.突然发现意外情况,紧急刹车做匀减速运动,加速度大小 2020-12-27 …
加速度的方向和△v(速度变化量)来决定.那么电梯加速向下的时候,加速度向下,那么速度变化量应该是正的 2020-12-31 …