早教吧作业答案频道 -->英语-->
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题哪里...的网友还看了以下:
6(m-n)³-12(n-m)²=6(m-n)^2[(m-n)+2]=6(m-n)^2(m-n+2 2020-04-09 …
6(m-n)³-12(n-m)²=6(m-n)^2[(m-n)+2]=6(m-n)^2(m-n+2 2020-04-09 …
在任意两个正整数m,n之间定义一种运算关系“*”:(m+1)*n=m*n+2,m*(n+1)=m* 2020-05-14 …
近代化学基础急一1.在用量子数表示核外电子运动状态时,写出下列各组中所缺少的量子数.(1)n=3, 2020-06-04 …
Mathematica画图的一个问题sol = Solve[{m^2 + n^2 == 36,(m 2020-06-27 …
创新应用题已知m,n为正整数,且m*m=n*n+11,则mn的值是多少?m^2=n^2+11m^2 2020-07-17 …
已知多项式2x^2+x+m有一个因式是(x-1),求m的值方法一设另一个因式为(2x+n),则2x 2020-07-25 …
cosmx+cosnx=1/2[(cos(m+n)+cos(m-n)x]这个和差化积公式怎cosm 2020-08-02 …
如果m≥n,那么下列各式中,正确的是如果m≥n,那么下列各式中正确的是.A.m+n/2≥nB.m+n 2020-11-08 …
速度啊,我明天上学(m+n)^2-6(m+n)+9看以下要求不要直接写答案(m+n)^2-6(m+n 2021-02-05 …