早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
如图所示是有氧呼吸过程的图解,据图回答:(1)有氧呼吸的全过程分为个阶段.a、b、c、e代表的物质 2020-05-14 …
怎样使用matlab解下面的代数方程?急.syms a b c d e;2*b^2=a^2+c^2 2020-05-16 …
用这些英文字母拼词这些英文字母打乱了顺序.一个题目一个词.第一题:r,c,t,a,e,s,r第二题 2020-05-16 …
如图所示的图解表示构成细胞的元素、化合物及其作用,a、b、c、d、e代表不同的小分子物质,A、B、 2020-05-17 …
用A,B,C,D,E,代表五进制中五个不相同的数字如果(ade)5(adc)5(aad)5是由小到 2020-05-22 …
纵横字谜之英语暑假作业题(s)(o)(r)(r)(n)(g)(r)(e))(a)(k)(k)(e) 2020-06-06 …
英语单词填空1.时间状语:d-r-n-2.场所:b-s-s-o-f-r--e-a-t-e-t3.教 2020-07-14 …
给出一棵树的逻辑结构T=(K,R),其中K={A,B,C,D,E,F,G,H,I,J}R={r}r 2020-07-22 …
1.化简(┐S∧(┐T∧┐R))∨(T∧R)∨(S∧R)2.用CP规则证明:E→(D∧C),(E→┐ 2020-10-31 …
图是三个经突触相联系的神经元示意图.现于箭头处施加一强刺激,不能检测到电位变化的位置是()(注:a、 2020-12-27 …