早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
求破解下面拼音组成的句子Y-Q,R-M-D-R-Z-S-N-M-D-X-K,G-L-W-M-90- 2020-05-17 …
设有字符序列(Q,H,C,Y,P,A,M,S,R,D,F,X),问新序列(F,H,C,D,P,A,M 2020-05-23 …
设有字符序列(Q,H,C,Y,P,A,M,S,R,D,F,X),则新序列(F,H,C, D,P,A, 2020-05-23 …
设有字符序列(Q,H,C,Y,P,A,M,S,R,D,F,X),问新序列(F,H,C,D,P,A,M 2020-05-23 …
设有字符序列(Q,H,C,Y,P,A,M,S,R,D,F,x),则新序列(H,C,Q,P,A,M,S 2020-05-23 …
设有字符序列(Q,H,C,Y,P,A,M,S,R,D,F,X),问新序列(F, H,C,D,P,A, 2020-05-24 …
设一组初始记录关键字序列为(Q,H,C,Y,P,A,M,S,R,D,F,X),则按字母升序的第一趟 2020-07-17 …
如图已知抛物线C:y^2=2px和圆M:(x-4)^2+y^2=1,过抛物线上一点H(x,y)(y 2020-07-26 …
谁能帮我组个英语单词①e、n、o、p、t、w、y②e③d、t、y④b、c、f、m、p、r、t、v⑤ 2020-07-29 …
求柱面的方程..准线为f(x,y)=0,z=0;母线的方向向量为s={l,m,n},则柱面的方程f 2020-07-31 …