早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
铜与1mol/L的硝酸反应,如果NO3ˉ浓度下降0.2mol/L,则溶液中c(H离子)同时下降( 2020-05-16 …
Cu与硝酸的反应Cu与一定体积的1mol/L的硝酸反应,如果NO3-的物质的量浓度下降0.2mol 2020-05-17 …
重新排列字母,写出单词1.s,a,p,e,c,2.r,o,e,t,c,k,3.d,c,o,o,t, 2020-06-06 …
a÷b=c,如果b>1,那么a()c. 2020-06-12 …
如果向量a=(1,0,1),b=(O,1,1)分别平行于平面c与d,且都与这两个平面的交线L垂直, 2020-06-27 …
1.在等腰梯形中,上底为A,下底为B,腰为C.如果B=2A,以C为边长的等腰三角形能作出几个且不重 2020-07-09 …
如图,B是直线l上的一点,线段AB与l的夹角为α(0°<α<180°),点C在l上,若以A、B、C 2020-07-18 …
已知三条不同的直线a,b,c在同一平面内,下列四条命题:①如果a//b,a⊥b,那么b⊥c;②如果 2020-07-29 …
已知三条不同的直线a,b,c在同一平面内,下列说法正确的个数是()①如果a∥b,a⊥c,那么b⊥c; 2020-11-02 …
可以用集合语言将“公理1:如果直线l上有两个点在平面α上,那么直线l在平面α上.”表述为()A.A⊊ 2020-11-21 …