/ Vijos / 讨论 / 过河 /

回溯做动规。。

#include<stdio.h>
long long L;
short S,T,M;
int x=0,l=0,i;
int stone(int s[])
{
int temp=1,j;
for(j=0;s[j]<=l;j++);
while(i<=s[j+1]){if(l-i>S&&l-i<T)temp=0;i++;}
return temp;
}
void go(int s[])
{
if(stone(s)==1)x++;
l+=i;
if(l>=L) return;
else go(s);
}
int main(void)
{
int i;
scanf("%d",&L);
scanf("%d %d %d",&S,&T,&M);
int s[M];
for(i=0;i<=M-1;i++)scanf("%d",&s[i]);
go(s);
printf("%d",x);
return 0;
}大神问题出在哪里

3 条评论

  • @ 2016-10-02 14:07:52

    *** [ Runtime Error. Gets = 0. ]***
    * Runtime Error[TOTAL SET = 10] *
    * Judging... Wrong Answer
    No.1: Runtime Error 201(3 more lines)
    No.2: Runtime Error 201(3 more lines)
    No.3: Runtime Error 201(3 more lines)
    To many error got. Stop judger.*

  • @ 2016-07-13 16:00:08

    6666666666666666666666666666666

  • @ 2014-12-21 15:27:46

    好吧不是回溯。。我也不太清楚是什么算法

  • 1

信息

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