早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
已知可逆反应M(g)+N(g)=P(g)+Q(g)若其浓度为C(M)=1molC(N)=2.4mo 2020-04-11 …
已知可逆反应:M(g)+N(g)===(可逆符号)P(g)+Q(g);△H>0.(为?.已知可逆反 2020-04-27 …
已知可逆反应:M(g)+N(g)P(g)+Q(g),△H>0.请回答下列问题:(1)在某温度下,反 2020-04-27 …
化学平衡常数与投料有关么.我自己想的.对于反应温度不变M(g)+N(g)=P(g)+Q(g)一起始 2020-06-24 …
来个人,化学平衡晕死了,我写的对不M(G)+N(G)=P(G)+Q(G)压强一定,不平衡M(G)+ 2020-07-04 …
已知某温度下可逆反应:M(g)+N(g)⇌P(g)+Q(g),反应物的初始浓度分别为:c0(M)= 2020-07-09 …
设非空集合M、N满足:M={x|f(x)=0},N={x|g(x)=0},P={x|f(x)g(x 2020-08-01 …
为什么m=G/g是求质量的万能公式?而m=pV却不是?(p在这里表示密度) 2020-11-07 …
高中函数已知f(x)=2^(x+1)是定义在R上的函数1.若f(x)可以表示为一个偶函数g(x)和奇 2020-12-22 …
设M={X|f(x)=0}≠Φ,N={x|g(x)=0}≠Φ,P={X|f(x)g(x)=0}≠Φ, 2020-12-25 …