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 ...
随机推荐
- xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is
method: select Xcode version in Command Line Tools in Location(Click Xcode and then Preferences) Bef ...
- Applications using Launch Screen Files and targetting iOS 7.1 and earlier need to also include a Launch Image in an Asset Catalog.
在使用xcode6建的项目时,有时在ios7模拟器下会出现一下情况 导航栏上方和tabbar下方会有黑边 并且会有一下警告: Applications using Launch Screen File ...
- VMware 虚拟机下挂载U盘
1.首先设置虚拟机为连接的可移动U盘 2.首先在虚拟机界面的情况下,插入U盘,U盘格式为fat32的 3.在mnt目录下新建一个文件夹usb 4.运用sudo fdisk -l /dev/sdb 来查 ...
- 杂项:game_navigation
ylbtech-杂项:game_navigation 1.返回顶部 1. 2. 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 6.返回顶部 作者:ylbtech出处: ...
- Python 之reduce()函数
reduce()函数: reduce()函数也是Python内置的一个高阶函数.reduce()函数接收的参数和 map()类似,一个函数 f,一个list,但行为和 map()不同,reduce() ...
- clc和clear命令的使用
clc命令是用来清除命令窗口的内容,这点不用多说.不管开启多少个应用程序,命令窗口只有一个,所以clc无论是在脚本m文件或者函数m文件调用时,clc命令都会清除命令窗口的内容.clear命令可以用来清 ...
- PCB拼板之多款矩形排样算法实现--学习
参考资料:<一种新型pcb合拼求解过程> 拼版合拼问题描述和求解过程 合拼问题描述 Pcb合拼问题是通过二维矩形组合排样而演化与扩展而形成的一种新拼版问题,把每个零件都看成一个规则的矩形进 ...
- Unity资源的查找
Object.Destroy static function Destroy(obj: Object, t: float = 0.0F): void; Description Removes a ...
- bzoj 1684: [Usaco2005 Oct]Close Encounter【数学(?)】
枚举分母,然后离他最近的分子只有两个,分别判断一下能不能用来更新答案即可 #include<iostream> #include<cstdio> #include<cma ...
- bzoj 1604: [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居【切比雪夫距离+并查集+multiset】
参考:http://hzwer.com/4361.html 坐标开long long,inf开大点 先曼哈顿转切比雪夫(x+y,x-y),距离就变成了max(x',y'): 先按x排序,维护两个指针, ...