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 ...
随机推荐
- [译]NUnit--Installation(三)
Installation NUnit安装程序默认安装文件路径为C:\Program Files\NUnit 2.6.2.根据用户选择安装的选项,安装文件有三个子文件夹:bin.doc.samples. ...
- SPOJ BEADS 最小字符串表示
SPOJ BEADS 给一个字符串(环) 问从哪个字符开始,字典序最小. 可以脑补到很多线性的解法,不过以下这个是最简单的,代码非常简单,就不解释了. #include<iostream> ...
- 深入理解JMM(Java内存模型) --(三)顺序一致性
数据竞争与顺序一致性保证 当程序未正确同步时,就会存在数据竞争.Java内存模型规范对数据竞争的定义如下: 在一个线程中写一个变量, 在另一个线程读同一个变量, 而且写和读没有通过同步来排序. 当代码 ...
- MySQL - MyCat 实现读写分离
前言 MyCat是一个彻底开源的,面向企业应用开发的大数据库集群,支持事务.ACID.可以替代MySQL的加强版数据库.其功能有可以视为MySQL集群的企业级数据库,用来替代昂贵的Oracle集群.融 ...
- 2017西安网络赛C_SUM
样例输入 1 1 样例输出 89999999999999999999999999 题意:利用上述公式,求出k的值 思路:找规律,找规律发现233个9,无论x是何值永远成立 (这种规律题尽量就不用跟队友 ...
- [译]The multi Interface
The multi Interfacemulti接口 The easy interface as described in detail in this document is a synchrono ...
- java IO流 之 字节输出流 OutputString()
Java学习重点之一:OutputStream 字节输出流的使用 FileOutPutStream:子类,写出数据的通道 步骤: 1.获取目标文件 2.创建通道(如果原来没有目标文件,则会自动创建一个 ...
- 6.12---前提两个对象的成员必须一致,才能将有数据的对象将数据传给反射获取的对象conver(有数据对象,目标对象)
//// Source code recreated from a .class file by IntelliJ IDEA// (powered by Fernflower decompiler)/ ...
- mysql之replace into与 insert into duplicat key for update
mysql实际应用中,我们在插入数据的时候,经常遇到主键冲突的情况,这是因为库中已经存在相同主键的数据,这时,我们只能更新数据:在判断是更新数据还是插入数据,我们还需要在此之前做一些必要的判断:在my ...
- QQ应用前景与范围文档
QQ软件 前景与范围文档 当前版本: 版本1 作 者: 李飞 完成日期: 2013年11月3日 1. 业务需求 1.1 应用背景 20世纪后期网络的应用和21世纪的飞速发展,网络已经 ...