CodeForces 382C【模拟】
来源:互联网 发布:java解析syslog 编辑:程序博客网 时间:2024/05/18 01:10
活生生打成了大模拟。。。
#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/22599025const 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;}
0 0
- CodeForces 382C【模拟】
- Codeforces 749C【模拟】
- CodeForces 118C 【模拟】
- Codeforces 863C 模拟
- codeforces 864C 模拟
- 模拟-Codeforces 777C
- 二进制 模拟 codeforces 485C
- Codeforces 230C Shifts(模拟)
- Codeforces 651C Watchmen【模拟】
- CodeForces 350C Bombs(模拟)
- Codeforces-----233C---Cycles模拟
- 爆搜 + 模拟 --- codeforces 475C
- codeforces 591C (模拟)
- 模拟--Codeforces 665C(简单模拟)
- Codeforces 48C The Race 模拟题
- codeforces 460C - Present 二分加模拟
- codeforces--C - Anya and Ghosts(贪心+模拟)
- codeforces 496C Removing Columns (模拟,思维)
- 差异增量备份和累积增量备份
- Ignite+CDH5.8安装配置
- 判断二维线段相交
- servlet中service() doGet() doPost() 方法
- YII2模型之增删改查
- CodeForces 382C【模拟】
- LINUX计算程序运行时间
- NNU_20161027_1
- js完成一个简易计算器
- 统计问题
- spring mvc @ResponseBody 返回中文乱码
- 解析shiny程序
- Libgdx之游戏源码合集
- html001-标题