HDU6147(2017百度之星程序设计大赛 - 复赛)[Pokémon GO II]--找规律

【链接】
hdu6147

【题目大意】

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

【解题报告】

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

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

这里写图片描述

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

#include<cstdio>
#define LL long long
using 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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值