早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
用四阶龙格库塔法求解矩阵微分方程要求电流就是求解矩阵微分方程:(R+pM(t))*I(t)+M(t 2020-05-13 …
一个线圈的电阻为R,感抗为XL,则其端电压U=I(R+XL)。 2020-05-30 …
将字母组成单词,并译成汉语1.m,e,r,m,u,s,汉语2.u,l,t,e,c,u,r,汉语3. 2020-06-04 …
对于纯电阻电路:已知:I、U,求:R=P=已知:R、U,求:I=P=已知:I、R,求:U=P=已知 2020-06-12 …
U=I*R还是U=I/R?电压等于电流乘以电阻还是电流除以电阻 2020-07-21 …
设全集I=R,M={x|lg(x^2-2)=lgx},N={x|√x+1≤2},则(M的补集)与N 2020-07-30 …
设全集U=R,M={a+b根号3|a,b是有理数}问以下哪项正确:AM是无理数的真子集B无理数是M 2020-08-01 …
线路中损失的电压:U=I*R式中I为线路中的电流、R为线路的电阻.(R=ρ*(L/S),电阻的大小与 2020-10-30 …
u=I/R这个是什么意思这个公式是用于,电阻、电流、电压的数值比较!但是让我一直不解的是这I/R中间 2020-10-30 …
为什么外电阻可变时△U/△I=r,而外电阻不可变时△U/△I=R.电源的伏安特性曲线的斜率为什么还能 2020-11-03 …