早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
初二题快一点哈已知k=(a+b-c)/c=(a-b+c)/b=(-a+b+c)/a已知k=(a+b 2020-05-13 …
I play with my friends tomorrow.改错 并改正I play(A) w 2020-05-17 …
选择题这四个式子哪个去括号正确()A.-(a-b+c)=-a-b-c,B.-(a-b+c)=-a+ 2020-06-03 …
二次函数的形状由哪个参数决定的.由a,b,c哪个参数决定的. 2020-06-12 …
如果有A,B,C,D,E,F六种生物,其中A,C同属不同种;B,C同科不同属;C,D同目不同科;B 2020-06-21 …
a#b=a+b-ab,问下列等式:a#b=b#a,a#0=a,(a#b)#c=a#(b#c)哪个正 2020-07-22 …
如图,直线DE过点A,∠B与哪个角是内错角,与哪个角是同旁内角?∠C与哪个角是内错角,与哪个角是同 2020-07-23 …
我看了百科里的合比定理,是这样的:若a/b=c/d,那么(a+b)/b=(c+d)/d(b、d≠0 2020-07-30 …
1、三个矢量a,b,c共面的充要条件是().A.(a*b)*c=0B.a.(b*c)=0C.(a. 2020-07-31 …
一个直角三角形如何判断哪个角是直角如果有个直角三角形ABC,没说哪个角是直角,那么如何判断哪个角是 2020-08-03 …