活生生打成了大模拟。。。

#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【模拟】的更多相关文章

  1. CodeForces - 427B (模拟题)

    Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Sub ...

  2. CodeForces - 404B(模拟题)

    Marathon Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Sta ...

  3. Codeforces 709B 模拟

    B. Checkpoints time limit per test:1 second memory limit per test:256 megabytes input:standard input ...

  4. CodeForces - 404A(模拟题)

    Valera and X Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit ...

  5. Codeforces 390A( 模拟题)

    Inna and Alarm Clock Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64 ...

  6. Codeforces 452D [模拟][贪心]

    题意: 给你k件衣服处理,告诉你洗衣机烘干机折叠机的数量,和它们处理一件衣服的时间,要求一件衣服在洗完之后必须立刻烘干,烘干之后必须立刻折叠,问所需的最小时间. 思路: 1.按照时间模拟 2.若洗完的 ...

  7. CodeForces - 796B 模拟

    思路:模拟移动即可,如果球落入洞中停止移动.注意:有可能第一个位置就是洞!! AC代码 #include <cstdio> #include <cmath> #include ...

  8. CodeForces - 864C-Bus-(模拟加油站问题)

    https://vjudge.net/problem/CodeForces-864C 题意:两地之间有个加油站,往返走k个单程,最少加油多少次. 大佬几十行代码就解决,我却要用一百多行的if语句模拟解 ...

  9. Codeforces 709C 模拟

    C. Letters Cyclic Shift time limit per test:1 second memory limit per test:256 megabytes input:stand ...

随机推荐

  1. PHP对称加密类

    <?php /** * Created by PhpStorm. * User: zongbinghuang * Date: 2017/7/31 * Time: 15:13 */ namespa ...

  2. ACM-BFS之Open the Lock——hdu1195(双向BFS)

    这道题的0基础版本号,暴力BFS及题目详情请戳:http://blog.csdn.net/lttree/article/details/24658031 上回书说道,要用双向BFS来尝试一下. 最终A ...

  3. Spring mvc接受集合类型参数的方法

    public String xxxxx(String xxxx, String xxxxx, @RequestParam("parameterList[]") List<St ...

  4. mongodb的锁和高并发

    1 mongodb的锁 mongodb使用的读写锁. 2 mongodb高并发 同样是读写锁造成的问题. 3 findandmodify 该操作是原子的.

  5. 使用 Visual Studio Code 运行 C# 及 Java 程序

    背景 很多情况下,我只是想要编写一个非常简单的 C# 或者 Java 程序,只有几行代码,看看运行结果而已.虽说 Visual Studio / Eclipse / IntelliJ IDEA 功能强 ...

  6. a little riak book

    a little riak book 的无聊总结 <pre name="code" class="python">#!/bin/bash # Ria ...

  7. 20170316 ABAP注意点

    1.debug 时在MODIFY db from table 后数据便提交了: 一般情况下,更新数据库需要commit,但debug会自动commit,程序结束也会自动commit. 2.使用at n ...

  8. 使用c函数库的两个函数strtok, strncpy遇到的问题记录

    1. strtok 问题背景: 解析形如 “1,2,3,4,5”字符串到整数数组 (1)计算个数 char* delim = ","; int count = 0; int *nu ...

  9. MD5 字符串问题

    早上来工位,大家再聊md5,无意中发现网上有个人提出个问题:研究了一下,挺有意思 有个串,通过各种办法得到的值不完全一样,下面请看细节: 假设这个字符串是 “ssss"我用的第一个办法应该是 ...

  10. Android系统shell中的clear命令实现【转】

    本文转载自:http://blog.csdn.net/morixinguan/article/details/73467845 之前一直不太清楚,当我们在shell命令行输入很多命令,会在屏幕上输出一 ...