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

#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. EasyPlayer实现视频播放局部缩放、广角平移功能(类似水滴直播,快手视频)

    本文转自:http://blog.csdn.net/jyt0551/article/details/56063869 视频播放局部缩放.广角平移功能 在预览图片的时候,利用手势控制图片的缩放.平移,已 ...

  2. throws ? catch checked unchecked

    ThrowableClass Error  (unchecked) Exception IOException (checked) RuntimeException (unchecked) publi ...

  3. 笔记,将CString转换为数值

           ANSI UNICODE TCHAR int    atoi    _wtoi  _ttoi long       atol    _wtol _ttol double   atof   ...

  4. Bestcoder round 18---A题(素数筛+素数打表+找三个素数其和==n)

    Primes Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  5. CSU - 1803 —— 数学题

    题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1803 Description  给出正整数 n 和 m,统计满足以下条件的正整数对 ...

  6. complex brain network

    Organization, development and function of complex brain networks The Brain as a Complex System: Usin ...

  7. IOS从背景图中取色

    ​1. [代码][其他]代码     void *bitmapData; //内存空间的指针,该内存空间的大小等于图像使用RGB通道所占用的字节数. static CGContextRef Creat ...

  8. APTM敏捷性能测试模型

    随着应用系统的日趋复杂,仅在系统测试和验收测试阶段执行性能测试已经不能满足迟早发现和解决系统性能瓶颈的要求,Connie Smith博士和Lloyd Winlliams博士在他们提出 的软件性能工程( ...

  9. 如何修改Windows的默认安装路径

    运行中输入regedit打开注册表编辑器 展开注册表“HKEY_LOCAL_MACHINE\Software\Microsoft\ Windows\ CurrentVersion”分支, 在窗口的右侧 ...

  10. tensorflow实现图像的翻转

    from:https://blog.csdn.net/uestc_c2_403/article/details/72703097 tensorflow内部含有实现图像翻转的函数为 tf.image.f ...