CodeForces 382C【模拟】
活生生打成了大模拟。。。
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
const double eps=1e-5;
const double pi=acos(-1.0);
//const int mod=1e9+7;
const int INF=0x3f3f3f3f;
//http://codeforces.com/contest/382/submission/22599025 const int N=1e5+10;
int a[N];
int ans[N],num;
int n; void shuchu()
{
sort(ans,ans+num);
int e=unique(ans,ans+num)-ans;
printf("%d\n",e);
for(int i=0; i<e; i++)
printf("%d ",ans[i]);
} map<int,int>mp;
int mp_num; int main()
{
scanf("%d",&n);
for(int i=1; i<=n; i++)
scanf("%d",&a[i]); sort(a+1,a+1+n); if(n==1)
{
puts("-1");
return 0;
}
if(n==2)
{
int d=a[n]-a[n-1];
if(d%2==1)
{
num=0;
ans[num++]=a[n-1]-d;
ans[num++]=a[n]+d;
shuchu();
}
else
{
num=0;
ans[num++]=a[n-1]-d;
ans[num++]=a[n]-d/2;
ans[num++]=a[n]+d;
shuchu();
}
return 0;
}
//3 4 4 5
//1 2 3
//1 2 4
int d1,temp,d2,num1,num2;
int dx1,dx2;
num2=num1=0;
d1=a[2]-a[1];
dx1=2;
num1++;
mp_num=1;
mp[d1]=1;
for(int i=3; i<=n; i++)
{
temp=a[i]-a[i-1];
if(!mp[temp])
{
mp[temp]=1;
mp_num++;
}
if(temp!=d1)
{
num2++;
dx2=i;
d2=temp;
}
else
num1++;
}
if(mp_num>=3)
{
puts("0");
return 0;
}
if(!num2)
{
num=0;
ans[num++]=a[1]-d1;
ans[num++]=a[n]+d1;
shuchu();
}
else
{
if(num1==1&&num2==1)
{
int res=a[dx2]-d1;
if(res*2==(a[dx2]+a[dx2-1]))
{
puts("1");
printf("%d\n",res);
return 0;
}
res=a[dx1]-d2;
if(res*2==(a[dx1]+a[dx1-1]))
{
puts("1");
printf("%d\n",a[dx1]-d2);
return 0;
}
puts("0");
}
else if(num2==1)
{
int res=a[dx2]-d1;
if(res*2==(a[dx2]+a[dx2-1]))
{
puts("1");
printf("%d\n",res);
}
else
puts("0");
}
else if(num1==1)
{
int res=a[dx1]-d2;
if(res*2==(a[dx1]+a[dx1-1]))
{
puts("1");
printf("%d\n",a[dx1]-d2);
}
else
puts("0");
}
else
puts("0");
}
return 0;
}
CodeForces 382C【模拟】的更多相关文章
- CodeForces - 427B (模拟题)
Prison Transfer Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Sub ...
- CodeForces - 404B(模拟题)
Marathon Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit Sta ...
- Codeforces 709B 模拟
B. Checkpoints time limit per test:1 second memory limit per test:256 megabytes input:standard input ...
- CodeForces - 404A(模拟题)
Valera and X Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- Codeforces 390A( 模拟题)
Inna and Alarm Clock Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64 ...
- Codeforces 452D [模拟][贪心]
题意: 给你k件衣服处理,告诉你洗衣机烘干机折叠机的数量,和它们处理一件衣服的时间,要求一件衣服在洗完之后必须立刻烘干,烘干之后必须立刻折叠,问所需的最小时间. 思路: 1.按照时间模拟 2.若洗完的 ...
- CodeForces - 796B 模拟
思路:模拟移动即可,如果球落入洞中停止移动.注意:有可能第一个位置就是洞!! AC代码 #include <cstdio> #include <cmath> #include ...
- CodeForces - 864C-Bus-(模拟加油站问题)
https://vjudge.net/problem/CodeForces-864C 题意:两地之间有个加油站,往返走k个单程,最少加油多少次. 大佬几十行代码就解决,我却要用一百多行的if语句模拟解 ...
- Codeforces 709C 模拟
C. Letters Cyclic Shift time limit per test:1 second memory limit per test:256 megabytes input:stand ...
随机推荐
- scikit-learn:4.2. Feature extraction(特征提取,不是特征选择)
http://scikit-learn.org/stable/modules/feature_extraction.html 带病在网吧里. ..... 写.求支持. .. 1.首先澄清两个概念:特征 ...
- EasyDarwin开源流媒体服务器将select改为epoll的方法
本文来自EasyDarwin团队Fantasy(fantasy(at)easydarwin.org) 一. EasyDarwin网络模型介绍 EventContext负责监听所有网络读写事件,Even ...
- 点击文本选中checkbox
<checbox文本编辑/> : 只点击checkbox时,才可以选中,点击文本时无法选中 <label><checbox文本编辑/></label ...
- 在图片上加字符-base64转图片-图片转base64
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- linux 网络设备,网卡配置 ,相关
网络设备,网卡配置: Eth0是物理网卡:唯一mac地址,Bcast:广播地址,MAsk:子网掩码, Lo:系统自带的回环的ip地址,可以做一些基本的测试应用,比如没有网卡就用127.0.0.1, r ...
- Vue 组件实例属性的使用
前言 因为最近面试了二.三十个人,发现大部分都还是只是停留在 Vue 文档的教程.有部分连教程这部分的文档也没看全.所以稍微写一点,让新上手的 Vuer 多了解 Vue 文档的其他更需要关注的点. 因 ...
- Vue源码探究-状态初始化
Vue源码探究-状态初始化 Vue源码探究-源码文件组织 Vue源码探究-虚拟DOM的渲染 本篇代码位于vue/src/core/instance/state.js 继续随着核心类的初始化展开探索其他 ...
- 千锋很火的SpringBoot实战开发教程视频
springboot是什么? Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员 ...
- Jmeter参数化_CSV Data Set Config
1. 在用函数助手进行参数化的时候遇到一个问题,每个线程组每次循环的时候读取的值都是一样的,为了解决这个问题,将函数助手替换为CSV_Data_Set_Config. 2. 添加配置元件csv dat ...
- WebRTC GitHub repo developer's guide
WebRTC GitHub repo developer's guide https://github.com/LingyuCoder/SkyRTC-demo WebRTC GitHub repo ...