SZU4
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue int n;
int mp[]; int main()
{
int i,j;
while(sf("%d",&n)==)
{
mem(mp,);
for(i=;i<n;i++)
{
sf("%d",&mp[i]);
}
sort(mp,mp+n);
if(n==)
{
pf("-1\n");
continue;
}
if(n==)
{
int d = mp[]-mp[];
if(d==)
{
pf("1\n%d\n",mp[]);
}
else if(d%==)
{
pf("3\n%d %d %d\n",mp[]-d,mp[]+d/,mp[]+d);
}
else
{
pf("2\n%d %d\n",mp[]-d,mp[]+d);
}
}
if(n==)
{
int d = mp[]-mp[];
int d2 = mp[]-mp[];
if(d==d2)
{
pf("2\n%d %d\n",mp[]-d,mp[]+d);
}
else if(d==d2*)
pf("1\n%d\n",mp[]+d2);
else if(d*==d2)
pf("1\n%d\n",mp[]+d);
else
pf("0\n");
}
if(n>)
{
int cnt=,cnt2=,find=,d2,ok=,x;
int d = mp[]-mp[];
for(i=;i<n-;i++)
{
int tmp = mp[i+]-mp[i];
if(d==tmp) cnt++;
else
{
if(!find)
{
d2=tmp;
find=;
x = i;
}
if(tmp==d2)
cnt2++;
else
{
ok=;break;
}
}
}
if(!ok)
{
pf("0\n");
continue;
}
if(cnt==n-)
{
pf("2\n%d %d\n",mp[]-d,mp[n-]+d);
}
else if(cnt==n-)
{
if(d2==d*)
{
pf("1\n%d\n",mp[x]+d);
}
else
pf("0\n");
}
else
{
if(d==d2*)
{
pf("1\n%d\n",mp[]+d2);
}
else
pf("0\n");
}
} }
}
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue int n;
int a[];
map<int,int> mp; int main()
{
int i,j;
while(sf("%d",&n)==)
{
mp.clear();
for(i=;i<n;i++)
{
sf("%d",&a[i]);
mp[a[i]]++;
}
map<int,int>::iterator it;
int res[],cnt=,ok=;
for(it=mp.begin();it!=mp.end();it++)
{
if(it->second)
{
res[cnt++] = it->first;
it->second--;
if(cnt==)
{
pf("%d %d %d\n",res[],res[],res[]);
cnt=;
ok=;
it = mp.begin();
}
}
}
if(!ok) pf("0\n");
}
}
SZU4的更多相关文章
随机推荐
- zTree API中刷新树没效果
想刷新树,但是根据API来的refresh无效 ---------------------------------------------------------------------------- ...
- 微信小程序之tabbar切卡
最近在研究小程序的时候,遇到了一个问题,就是tabbar切卡,在android上有fragment,在RN上也有提供一个第三方的组件来用,微信小程序,好像没有专门的一个组件来实现这个功能,度娘了大半天 ...
- [ActionScript 3.0] 简单倒计时
import flash.utils.Timer; import flash.events.TimerEvent; import flash.text.TextField; var text:Text ...
- [ActionScript 3.0] PrintJob打印功能
package { import flash.display.Bitmap; import flash.display.Sprite; import flash.events.MouseEvent; ...
- ubuntu14.04部署kickstart
转自:http://www.mamicode.com/info-detail-1646465.html kickstart用于在内网自动安装系统. 使用pxe安装系统需要安装dhcp,tftp,htt ...
- wireshark的安装
wireshark是一款很强大的软件,我第一次接触是在计算机网络的课上,正是运用这款软件的时候. 下面我来介绍一下当初我安装时候的问题,方便大家的使用和参考 Wireshark(前称Ethereal) ...
- JAVA 集合随笔
JAVA中提供了现成操纵数据的集合,使得我们在开发中基本不用自己动手实现复杂的数据结构,来保存和操纵数据. 所以当我们有了基本的数据结构知识,会合理利用JAVA提供的集合就好啦. JDK1.8;(仅列 ...
- React.Children详解
React.Children提供了处理this.props.children的工具,this.props.children可以任何数据(组件.字符串.函数等等).React.children有5个方法 ...
- createFile
#include<iostream> #include<windows.h> #include<stdio.h> using namespace std; int ...
- 一些排序 (python实现)
►快速排序 <时间复杂度O(n㏒n)> def partition(li,left,right): tmp = li[left] while left < right: while ...