HDU6147(2017百度之星程序设计大赛

来源:互联网 发布:ubuntu无法登录界面 编辑:程序博客网 时间:2024/06/05 13:26

【链接】
hdu6147

【题目大意】

看题面可以理解。博主已经懒得打了

【解题报告】

经过日复一日,年复一年的画图终究得出这题是道规律题woc!!!!!

如果路线相交只会出现两种情况,如下:

这里写图片描述

所以只需要判一判就出结果了。

#include<cstdio>#define LL long longusing namespace std;const int maxn=1000005;int T,n,ans,a[maxn];inline int Read(){    int res=0;    char ch=getchar();    while (ch<'0'||ch>'9') ch=getchar();    while (ch>='0'&&ch<='9') res=res*10+ch-48,ch=getchar();    return res;}void Work(){    n=Read();     for (int i=1; i<=n; i++) a[i]=Read();    for (int i=4; i<=n; i++)     if ((a[i]>=a[i-2]&&a[i-1]<=a[i-3])||      (i>=6&&a[i-3]>=a[i-1]&&a[i-2]>=a[i-4]&&a[i-1]+a[i-5]>=a[i-3]&&a[i]+a[i-4]>=a[i-2])||       (i>=5&&a[i-1]==a[i-3]&&a[i]<=a[i-2]&&a[i]+a[i-4]>=a[i-2])) {printf("%d\n",i); return;}    printf("Catch you\n");}int main(){    freopen("6147.in","r",stdin);    freopen("6147.out","w",stdout);    T=Read();    while (T--) Work();    return 0;}
原创粉丝点击