早教吧作业答案频道 -->英语-->
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.f(x)=x+a/x(a属于R),g(x)=lnx若关于x的方程g(x)/X的平方=f(x)- 2020-04-27 …
有关拉格朗日定理(群论)的问题拉格朗日定理如下:设是群的一个子群,那么R={|a属于G,b属于G, 2020-05-17 …
颜色包含四个维度——R,G,B,A(透明度);位置包含四个维度——X,Y,Z,W(相对坐标)前面的 2020-06-14 …
如图所示,在半径为R的半圆形碗的光滑表面上,一质量为m的小球以角速度ω在水平面内作匀速圆周运动,该 2020-07-08 …
matlab求解二阶导数方程,四个方程四个未知量>>symst>>E=32;G=10.81;b=2 2020-07-19 …
[高一数学]已知全集为R,集合A={x|f(x)=0},B={x|g(x)=0},则不等式f(x) 2020-07-29 …
求高数题设函数g(r)有二阶导数,f(x,y)=g(r),r=根号下x平方加y平方,求证:f对x的 2020-07-30 …
基本初等函数1.定义在R上的偶函数f(x)和奇函数g(X)满足f(x)+g(X)=e^x,求g(x 2020-08-02 …
四元一次方程组等式变换.在计算机数字图像水印处理中用到的四元一次方程组.已知常数R、G、B、S;未 2020-08-03 …
这个Mathematica三维图为什么画不出来w=1403L=150a=650w1=w/2//Nr= 2020-10-31 …