杭电 acm 2044题 交上去一直wa 求错误,不要答案
#include<stdio.h>#include<stdlib.h>intmain(){inti,m,n,j;longlong*p;p=(longlong*)callo...
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i, m, n, j;
long long *p;
p = (long long *)calloc(2,sizeof(long long));
p[0] = 0;
p[1] = 1;
scanf("%d",&i);
while(i)
{
i--;
scanf("%d%d",&n,&m);
p = (long long *)realloc(p,(m-n+2)*sizeof(long long));
for(j=2; j<m-n+2; j++)
{
p[j] = p[j-1] + p[j-2];
}
printf("%lld\n",p[m-n+1]);
}
return 0;
}
不要发答案,我只想知道错哪了 展开
#include <stdlib.h>
int main()
{
int i, m, n, j;
long long *p;
p = (long long *)calloc(2,sizeof(long long));
p[0] = 0;
p[1] = 1;
scanf("%d",&i);
while(i)
{
i--;
scanf("%d%d",&n,&m);
p = (long long *)realloc(p,(m-n+2)*sizeof(long long));
for(j=2; j<m-n+2; j++)
{
p[j] = p[j-1] + p[j-2];
}
printf("%lld\n",p[m-n+1]);
}
return 0;
}
不要发答案,我只想知道错哪了 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询