早教吧作业答案频道 -->英语-->
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(A)=2,A^2+2A=0,求特征值.都得到a(a+2)=0.为什么得到a=0 2020-04-13 …
设两个关系R(A,B)和S(A,C)。则下列关系代数表达式中必与等价的是A.ⅡA.B.C(R×S)B 2020-05-23 …
假设有如下的关系R和S:若关系R和S的关系代数操作的结果如下,这是执行了A.R×SB.R×SC.R× 2020-05-23 …
设有关系R(A,B,C)和S(A,D,E,F),且R.A和S.A取自同一个域,与下面SQL语句: S 2020-05-23 …
给定关系R(A,B,C,D)和关系S(C,D,E),对其进行自然连接运算R??s后的属性列为()个; 2020-05-26 …
求解一个6阶的方阵R,满足条件:R*R'=diag(1,1,1,1,1,1)并且[0.0535,0 2020-06-22 …
完全平方式问题R'/(R+R')^2求最大值,把下面的平方式展开变成R'/(R^2+2RR'+R' 2020-06-27 …
离散数学二元关系,设R和S是集合A上的对称关系,证明:R。S具有对称性,当且仅当R。S=S。R 2020-08-01 …
看到一个题不太理解,设OB=R则S半圆=1/2π(R/2)^2=1/8πR^2S扇OBC=45/36 2020-11-21 …
Foreachofthefollowing,giveabijectionffromAtoB.Yous 2020-11-26 …