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 ...
随机推荐
- Windows10、ARM开发板、VMware虚拟机同时连接Internet
前段时间有人遇到一些网络连接问题,让我帮忙处理,他想让ARM开发板连接外网,可以连接网络数据库,同时保证自己的电脑可以上网. 本来说直接可以连接一个路由器,分配一个内网IP给ARM就可以了,但是当时那 ...
- 洛谷 P1573 栈的操作
题目描述 现在有四个栈,其中前三个为空,第四个栈从栈顶到栈底分别为1,2,3,-,n.每一个栈只支持一种操作:弹出并压入.它指的是把其中一个栈A的栈顶元素x弹出,并马上压入任意一个栈B中.但是这样的操 ...
- POJ1385 Lifting the Stone 多边形重心
POJ1385 给定n个顶点 顺序连成多边形 求重心 n<=1e+6 比较裸的重心问题 没有特别数据 由于答案保留两位小数四舍五入 需要+0.0005消除误差 #include<iostr ...
- java笔记线程方式1优先级
* 我们的线程没有设置优先级,肯定有默认优先级. * 那么,默认优先级是多少呢? * 如何获取线程对象的优先级? * public final int getPriority():返回线程对象的优 ...
- Hibernate的表之间的关系
表:A.B 一对多关系:A中的一个字段的记录(主键)引用B中的多个记录(外键) 多对一关系:A中的一个字段的记录(外键)引用B中的一个记录(主键) 一对一关系:A.B两个表的关联字段都是主键 多对多关 ...
- [App Store Connect帮助]五、管理构建版本(1)上传构建版本概述
在您添加 App 至您的帐户之后,您可以使用 Xcode 或 Application Loader 来上传构建版本.稍后,您可以随着您 App 的更改上传更多构建版本.分发构建版本以供测试,或提交您的 ...
- 51nod1265判断四点共面
1265 四点共面 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 给出三维空间上的四个点(点与点的位置均不相同),判断这4个点是否在同一个平面内(4点共 ...
- 题解报告:hdu 1035 Robot Motion(简单搜索一遍)
Problem Description A robot has been programmed to follow the instructions in its path. Instructions ...
- 93. [NOIP2001] 数的划分
问题描述 将整数n分成k份,且每份不能为空,任意两种方案不能相同(不考虑顺序). 例如:n=7,k=3,下面三种分法被认为是相同的. 1,1,5; 1,5,1; 5,1,1; 问有多少种不同的分法. ...
- TypeError: string indices must be integers, not str
1. TypeError: string indices must be integers, not str 字符串类型取第index个字符的时候,应该传入int而不是str.如 1 a='abcde ...