早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
补全下面的对话.A.l()Lucy.What's(B.Mynameisjim.A.Niceto() 2020-04-26 …
f(x)=akx^k+a(k-1)x^(k-1).+a0A为n阶矩阵,若f(A)=O,则A可逆并写 2020-05-17 …
关于矩阵?1、若A^k=O,(k是正整数),求证:(I-A)^-1=I+A+A^2+……+A^k- 2020-06-12 …
四边形OABC的四个顶点坐标分别是O(O,O)A(6,2)B(4,6)C(2,6),直线Y=KX( 2020-06-13 …
选择元音字母在单词中发音不同的一项.1;A:h(a)nd;B:f(a)ce;C:(a)pple.2 2020-06-17 …
1.下列加点字注音、字型都有错误的一项是()A谋取(móu)颤颤巍巍(chàn)B哂笑(xī)莫忠 2020-06-19 …
线性代数一个证明题设A^k=o(k为正整数),证明:(E-A)^-1=E+A+A^2+……+A^k 2020-07-20 …
若A^k=o(k为正整数)求证(E-A)^(-1)=E+A+A^2+……+A^(K-1) 2020-07-20 …
已知圆上2点及夹角,求圆心直角坐标上一圆,已知圆上2点A(x1,y1),B(x2,y2)及这两点与 2020-07-26 …
若x,y满足约束条件,目标函数仅在点(1,0)处取得最小值,则a的取值范围是w.w.w.k.s.5. 2020-11-01 …