Gym - 101670A Amusement Anticipation(CTU Open Contest 2017 签到题)
倒着找处于最后位置的等差数列的开头的位置。
例:
1 5 3 4 5 6
3 4 5 6是等差数列,它的开头的位置是3
PS:
读题真的很重要!!!!多组输入,上来就读错了!!
代码:
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define FRE() freopen("in.txt","r",stdin)
using namespace std;
typedef long long ll;
const int maxn = 5e3+;
int dp[maxn][maxn];
int a[maxn]; int main(){
//FRE();
int n;
while(scanf("%d",&n)!=EOF){
for(int i=; i<=n; i++){
scanf("%d",&a[i]);
}
int d = a[n] - a[n-],index = ,ok = ;
for(int i = n-; i>=; i--){
if(a[i+]-a[i] != d){
index = i;
ok = ;
break;
}
}
if(ok)
printf("%d\n",index+);
else
printf("%d\n",index);
}
return ;
}
/*
PutIn:
5
1 2 3 4 5
7
1 2 3 4 5 8 8
3
7 5 2
PutOut:
1
6
2
*/
Gym - 101670A Amusement Anticipation(CTU Open Contest 2017 签到题)的更多相关文章
- Gym - 101670H Go Northwest!(CTU Open Contest 2017 思维题+map)
题目: Go Northwest! is a game usually played in the park main hall when occasional rainy weather disco ...
- (寒假开黑gym)2018 ACM-ICPC, Syrian Collegiate Programming Contest(爽题)
layout: post title: (寒假开黑gym)2018 ACM-ICPC, Syrian Collegiate Programming Contest(爽题) author: " ...
- Gym - 101670F Shooting Gallery(CTU Open Contest 2017 区间dp)
题目&题意:(有点难读...) 给出一个数字序列,找出一个区间,当删除这个区间中的两个相同的数字后,只保留这两个数字之间的序列,然后继续删除相同的数字,问最多可以实行多少次删除操作. 例如: ...
- Gym - 101670G Ice cream samples(CTU Open Contest 2017 尺取法)
题目: To encourage visitors active movement among the attractions, a circular path with ice cream stan ...
- Gym - 101670E Forest Picture (CTU Open Contest 2017 模拟)
题目: https://cn.vjudge.net/problem/1451310/origin 题意&思路: 纯粹模拟. 大体题意是这样的: 1.有人要在一个10-9<=x<=1 ...
- Gym - 101670H Dark Ride with Monsters(CTU Open Contest 2017 贪心)
题目: A narrow gauge train drives the visitors through the sequence of chambers in the Dark Ride attra ...
- Gym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)
题目:链接 思路: 多画出几个情况就可以找出规律来了 Knight (当大于2的时候只要两种颜色相间出现就可以了) King(当大于等于3的时候,总可以用四种形式来补色,具体如下) Bishop(斜 ...
- Gym - 101670B Pond Cascade(CTU Open Contest 2017 贪心,二分)
题目: The cascade of water slides has been installed in the park recently and it has to be tested. The ...
- Gym - 101670J Punching Power(CTU Open Contest 2017 最大独立集)
题目: The park management finally decided to install some popular boxing machines at various strategic ...
随机推荐
- ViewPager嵌套ViewPager后子ViewPager滑动不正常问题
ViewPager嵌套ViewPager后,滑动事件没法在子ViewPager里面响应. 解决办法是自定义子ViewPager. 以下代码是转载的,经本人测试,可以用!!! 转载地址:http://b ...
- [NOI 2014] 起床困难综合征
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=3668 [算法] 从高位向低位贪心即可 时间复杂度 : O(30N) [代码] #in ...
- MySQL:目录
ylbtech-MySQL:目录 1.返回顶部 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 6.返回顶部 作者:ylbtech出处:http://ylbtech ...
- HTML5来了,7个混合式移动开发框架
在这个时间开始学习移动开发真是最好不过了,每个人应该都有一些移动应用的创意,而且你并不需要任何的原生应用编程经验,你只需要一些HTML的相关知识,懂一些CSS和JavaScript就够了.如果你总听别 ...
- 洛谷 P3121 [USACO15FEB]审查(黄金)Censoring (Gold) 【AC自动机+栈】
这个和bzoj同名题不一样,有多个匹配串 但是思路是一样的,写个AC自动机,同样是开两个栈,一个存字符,一个存当前点在trie树上的位置,然后如果到了某个匹配串的末尾,则弹栈 #include< ...
- bzoj 1611: [Usaco2008 Feb]Meteor Shower流星雨【BFS】
t记录每个格子最早被砸的时间,bfs(x,y,t)表示当前状态为(x,y)格子,时间为t.因为bfs,所以先搜到的t一定小于后搜到的,所以一个格子搜一次就行 #include<iostream& ...
- codevs1183 泥泞的道路(01分数规划)
1183 泥泞的道路 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description CS有n个小区,并且任意小区之间都有两 ...
- npm更换为淘宝镜像源
1.通过config命令 1 2 npm config set registry http://registry.cnpmjs.org npm info underscore (如果上面配置正确这 ...
- Net 发布网站中遇到的几点问题
1.windows 身份验证设置 打开IIS==>=>找到网站==> 身份验证==>打开功能==>启用windows身份验证 网站设置: 博客参考: http://blo ...
- [C++ STL] list使用详解
一.list介绍: List由双向链表(doubly linked list)实现而成,元素也存放在堆中,每个元素都是放在一块内存中,他的内存空间可以是不连续的,通过指针来进行数据的访问,这个特点使得 ...