早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
读拼音写字词。xiāodàolùzhùzhízhuā除意接住bùmǎnzúróngyìzhùfú宣 2020-05-13 …
已知向量a=(根号3 sin3x,-y),b=(m,cos3x-m) (m∈R) 且a+b=0 设 2020-05-16 …
.在反应M+2N=R+2Q中.在反应M+2N=R+2Q中,3.2gM与N恰好完全反应后,生成8.8 2020-05-21 …
[20分][高一不等式]已知a,b,m,n∈R+,设p=Sqrt(ab)+Sqrt(cd),q=S 2020-05-23 …
已知函数f(x)=m•2x+2•3x,m∈R.(1)当m=-9时,求满足f(x+1)>f(x)的实 2020-06-12 …
设A为m×n型矩阵,B为n×m型矩阵,E为m阶单位矩阵,若AB=E,则()A.r(A)=m,r(B 2020-06-30 …
谁能帮我组个英语单词①e、n、o、p、t、w、y②e③d、t、y④b、c、f、m、p、r、t、v⑤ 2020-07-29 …
下列选项中的M和P表示同一集合的是()A.M=(x属于R丨x²+0.01=0),P=(x丨x²=0 2020-07-30 …
已知命题p:复数得=m−9中1+9中(m∈R,中是虚数单位)在复平面上对应的点不可能位于第一象限; 2020-08-01 …
下列各选项中的M与P表示同一个集合的是()A.M={x∈R|x2+0.01=0},P={x|x2=0 2020-10-31 …