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

#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. bzoj-2251 外星联络

    题意: 给出一个字符串,求出现次数超过1的子串的出现个数. 字符串长度<=3000: 题解: 题目问的是子串的个数.那么首先我们要找到全部的子串. 而字符串的全部后缀的前缀能够不重不漏的表示全部 ...

  2. 【BZOJ3252】攻略 DFS序+线段树(模拟费用流)

    [BZOJ3252]攻略 Description 题目简述:树版[k取方格数] 众所周知,桂木桂马是攻略之神,开启攻略之神模式后,他可以同时攻略k部游戏. 今天他得到了一款新游戏<XX半岛> ...

  3. css常用总结

    1.固定一个层在页面的位置,不受滚动条影响, 属性position:fixed,如: .tbar{ height:200px;width:60px;background-color:#666;posi ...

  4. ZOJ 3551 Bloodsucker <概率DP>

    题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3551 题意:开始有N-1个人和一个吸血鬼, 每天有两个生物见面,当人 ...

  5. if __name__

     我们经常在python 程序中看到 if __name__ == '__main__' :这代表什么意思?    python中 模块是对象,并且所有的模块都有一个内置属性 __name__.一个模 ...

  6. Netty聊天器(实战一):从0开始实战100w级流量应用

    Java 聊天程序(百万级流量实战一):系统介绍 疯狂创客圈 Java 分布式聊天室[ 亿级流量]实战系列之14 [博客园 总入口 ] 源码IDEA工程获取链接:Java 聊天室 实战 源码 写在前面 ...

  7. IOS 文件夹结构

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/MyGameZone/article/details/24494765 IOS文件夹结构 说明 这些仅 ...

  8. C++软件工程师,你该会什么?

    请尊重原创: 转载注明来源   原创在这里哦 C语言广泛用于基础软件.桌面系统.网络通信.音频视频.游戏娱乐等诸多领域.是世界上使用最广泛的编程语言之一.随着物联网技术的发展,C/C++技术在3G网络 ...

  9. CISCO-路由器交换机IOS被删,恢复方法

    方式一,tftpdnld方式恢复Router 2600 IOS 1) 将计算机串口和路由器console口相连 一定将计算机网口与路由器第一个以太口f0/0相连. 2) 启动TFTP服务器,并将要下载 ...

  10. CodeForces - 762E:Radio stations (CDQ分治||排序二分)

    In the lattice points of the coordinate line there are n radio stations, the i-th of which is descri ...