早教吧作业答案频道 -->英语-->
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(g)+B(g)=C(g)△H=△H1D(g)+B(g)=E(g)△H=△H2,若A和D混合 2020-05-20 …
化学高手们帮帮我啊?超级急的啊!有A,B,C三种常见固体,投入水中分别产生D,E,F三种气体,他们 2020-06-23 …
选出下列黑体字注音没有错误的一项()A.颠簸(bō)烟垢(gòu)瘸腿(qué)B.打夯(hāng 2020-07-02 …
H和K是群G的正规子群,且HK=G.证:G/(H∩K)是到(G/H)×(G/K)的同构.我的思路是 2020-07-09 …
下列各项,注音有误的一项是A.勾gòu勾当梏gù桎zhì梏盥guàn盥洗室B.犷kuáng粗犷皈g 2020-07-15 …
下面的反应中,哪一个满足ΔH°rxn=ΔH°f?A.½N2(g)+½O2(g)→NO(g)B.CO 2020-07-21 …
导数乘法证明中h是什么意思?(f(x)g(x))'=lim(h→0)[f(x+h)g(x+h)-f 2020-07-22 …
推断题:现有如下反应(反应条件均不给),推断物质⑴A→B+C+D⑵C+E→C+F+D⑶D+G→H⑷ 2020-07-30 …
三元一次方程组a*x+b*y+c*z+d=0,e*x+f*y+g*z+h=0,i*x+j*y+k* 2020-08-03 …
下列词语中加点的字读音有错误的一组是()A.恫吓hè档案dàng果脯fǔ惩前毖后bìB.桎梏gù尸骸 2020-12-29 …