早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
voidmain(){inta=0,b=0,d=0;char*s="xcbc3abcd";for( 2020-04-27 …
it’s not polite to ask()A.the price B.the dat 2020-05-16 …
A.πA,D(σC=D(R×S))B.πA,R,D(σS,C=R,D/(R×S))C.πA,R,D( 2020-05-26 …
A.πA,D(σC=D(R×S))B.πA,R.D(σR.C=S.D(R×S))C.πA,R.D(σ 2020-05-26 …
A.πA,D(σC=D(R×S))B.πA,R.D(σS.C=R.D(R×S))C.πA,R.D(σ 2020-05-26 …
设一组初始记录关键字序列为(Q,H,C,Y,P,A,M,S,R,D,F,X),则按字母升序的第一趟 2020-07-17 …
multiplydefinedsymbolsfound#includemain(){doublea 2020-07-23 …
帮我解这些方程啊.一个过程就行.1.4x+y-z=123x+2y+z=-5x-y+5z=12.2a+ 2020-10-31 …
如图所示,AB,CD为铁块,当开关S闭合后,AB,CD被磁化,则它们被磁化后的磁极为()A.A为N极 2020-11-01 …
一个自然数n的所有数字之和记为S(n),若n+S(n)=2009,则n为多少.这样做可不可以:设S( 2020-12-07 …