/ Vijos / 讨论 / 过河 /

为什么不行啊。。。

#include<stdio.h>
long long L;
int S,T,M;
int i,j,min,ans,temp;
int trace(int s[],int x)
{
if(x>L)
{
if(ans<min)min=ans;
}
else for(i=S;i<=T;i++)
{
temp=0;
for(j=0;j<=M-1;j++)if(s[j]==x+i)temp=1;
if(temp==0){trace(s,x+i);}
else if(i==T){ans++;trace(s,x+i);ans--;}
}
}
int main(void)
{
scanf("%d",&L);
scanf("%d %d %d",&S,&T,&M);
if(M>0)
{
int s[M];
for(i=0;i<=M-1;i++)scanf("%d",&s[i]);
for(i=0;i<=M-2;i++)for(j=0;j<=M-2;j++)
if(s[j]>s[j+1]){temp=s[j];s[j]=s[j+1];s[j+1]=temp;}
min=L;ans=0;temp=0;
trace(s,0);
printf("%d",min);
}
else printf("0");
return 0;
}

1 条评论

  • @ 2014-12-28 19:05:59

    评测结果
    编译成功

    foo.c: In function 'main':
    foo.c:21:5: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'long long int *' [-Wformat]
    foo.c: In function 'trace':
    foo.c:18:1: warning: control reaches end of non-void function [-Wreturn-type]
    测试数据 #0: Accepted, time = 0 ms, mem = 992 KiB, score = 10
    测试数据 #1: WrongAnswer, time = 0 ms, mem = 572 KiB, score = 0
    测试数据 #2: Accepted, time = 0 ms, mem = 596 KiB, score = 10
    测试数据 #3: RuntimeError, time = 0 ms, mem = 2548 KiB, score = 0
    测试数据 #4: RuntimeError, time = 7 ms, mem = 2552 KiB, score = 0
    测试数据 #5: RuntimeError, time = 0 ms, mem = 2560 KiB, score = 0
    测试数据 #6: RuntimeError, time = 0 ms, mem = 2556 KiB, score = 0
    测试数据 #7: RuntimeError, time = 0 ms, mem = 2552 KiB, score = 0
    测试数据 #8: RuntimeError, time = 15 ms, mem = 2548 KiB, score = 0
    测试数据 #9: RuntimeError, time = 15 ms, mem = 2548 KiB, score = 0
    RuntimeError, time = 37 ms, mem = 2560 KiB, score = 20

  • 1

信息

ID
1002
难度
7
分类
动态规划 点击显示
标签
递交数
25264
已通过
4390
通过率
17%
被复制
76
上传者