早教吧作业答案频道 -->英语-->
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)N•M;(2)J/s;(3)W•S;(4)N•M/s. 2020-05-13 …
请教高手给出概率解释(大三以上的进)C(m,k)*C(n-m,r-k)/C(n,r)=C(r,k) 2020-06-11 …
z,y,x,w,v,u,t,z,y,s,r,q,p,o,z,y,n,m,l,k,j,z,y,i,, 2020-06-12 …
设G是平面有N个顶点M条边,F个面,K个连通分支,证明:N-M+F=K=I错了错了,证明的是:N- 2020-06-12 …
几个化学元素C,H,O,N,P,S,K,Ca,Mg各指什么! 2020-07-14 …
关于分式的一个小问题书上说(N/M)K=(NK/MK)K为系数,那么(Y/3X2)3等于多少?那个 2020-07-30 …
另外,如果我想把这一句也加进去怎么办?for/f"delims="%%ain('dir/a-d/s/ 2020-11-01 …
在国际单位制中,功率的单位是,简称,1W=J/s=N*m/s。工程技术上还常用kW、MW作功率的单位 2020-11-01 …
在国际单位制中,功率的单位是],简称],1W=J/s=N*m/s。工程技术上还常用kW、MW作功率的 2020-11-01 …
排列证明:P(m,n)=P(k,n)P(m-k,n-k)P(m,n)=n!/(n-m)!P(k,n) 2020-12-05 …