早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
一道超级难的题目(必须有丰富的理解能力,才能理解题目的意思)如果1代表A或B,2代表C或D,3代表 2020-04-26 …
s=0:t=o:u=0fori=1to3forj=1toifork=jto3s=s+1nextkt 2020-05-14 …
函数f(x)在(0,+∞)连续,f(1)=5/2,对所有x,t∈(0,+∞),满足∫(1,x)f( 2020-05-19 …
u,i,n,c,o,s可以拼成什么单词?还有,o,s,l,h,u,d还有,t,p.s.n.e.r, 2020-05-23 …
A.t[1]=u[1]∧t[2]=u[2]∧t[3]=V[4]B.t[1]=v[1]∧t[2]=u[ 2020-05-26 …
A.t[1]=u[1]∧t[2]=u[2]∧t[3]=v[3]B.t[1]=u[1]∧t[2]=u[ 2020-05-26 …
设有如下关系:关系代数表达式R÷S的结果集为(17)。A.u[2]=v[1]t[1]=u[1]t[2 2020-05-26 …
在|哺|乳|动|物|的|thec|o|m|m|u|n|i|t|y||行|为|中|在|哺|乳|动|物 2020-06-29 …
利用电能公式W=IUt和欧姆定律I=U/R推导:(1)w=I的平方乘以R乘以t.(2)W=U的平方 2020-07-15 …
9个字母,已知有:c,o,t,l,n,u,o无顺序.是什么单词啊.急还有1个i,还有e,总共是:c, 2020-12-05 …