早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
英语达.请把下列个题中的字母组成一个你所学过的单词.o,m,w,l,c,e,ee,g,h,t,io 2020-05-13 …
设A是n阶矩阵A^2=E,证明r(A+E)+r(A-E)=n,的一步证明过程不懂由A^2=E,得A 2020-05-14 …
设A是n阶矩阵,A=E+xy^T,x与y都是n*1矩阵,且x^T*y=2,求A的特征值、特征向量易 2020-06-30 …
重组字母为单词e,e,r,w,he,e,r,t,he,e,se,a,sw,m,s,ir,t,p,i 2020-07-09 …
RSA算法中r无法满足e*r%t==1的问题p=47;q=59;t=(p-1)×(q-1)=266 2020-07-23 …
RSA算法中r无法满足e*r%t==1的问题p=47;q=59;t=(p-1)×(q-1)=266 2020-07-23 …
写单词,这些单词打乱顺序了!:1.d,f,e,n,i,f,e,r,t,()2.g,h,o,e,t, 2020-07-26 …
()1.A.Hello,Jack.()2.A.E-R-A-S-E-R.()3.A.Yes,itis. 2020-10-30 …
字母组词1.e,t,n,l,a,c,r2.h,e,c,p,a3.t,a,e,r,w4.i,t,a,a 2020-10-31 …
这几个字母怎么拼才是单词呢?B-E-E-N-M-O-R-VA-E-R-T-WA-B-C-D-O-P- 2021-02-09 …