早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
设a=(√5-1)/2,求(a^5+a^4-2a^3-a^2-a+2)/a^3-a∵2a=√5-1 2020-04-05 …
1.给定抛物线y=2(x的平方)设点A(a,o)(a>1),p是抛物线上一点,且PA的长度等于d, 2020-04-12 …
∵EM是⊙O的切线,怎么推出EB•EC=EM2①?,看题后回答.(2005•温州)如图,已知四边形 2020-05-21 …
设直线l的方程为(a+1)x-y+2-a=o(a∈R)(1)若L在两坐标轴上截距相等,求L的方程( 2020-06-07 …
19.设A,B为圆x*2+y*2=1上两点,O为坐标原点(A,O,B不共线)(1)求证:向量OA+ 2020-06-12 …
A/O排泥问题:arm:A/O后面有个沉淀池.排泥是只排沉淀池的泥么?如果是这样,想保证A/O的泥 2020-07-07 …
一、已知数集M满足条件:若a∈M,则(1+a)/(1-a)∈M(a≠0,a≠±1)(1)若3∈M, 2020-07-30 …
已知集合A={x|x²+(a-1)x-a>o},B={x|x²+(a+b)x+abo,a≠b},M 2020-07-30 …
等边三角形ABC,AB=a,O为三角形的中心,过O点的直线交AB于M,交AC于N,求1.等边三角形 2020-08-03 …
阅读下面材料:在数学课上,老师提出如下问题:尺规作如图1:作∠A'O'B'=∠AOB.已知:∠AOB 2020-11-06 …