CF 382C
http://codeforces.com/problemset/problem/382/C
读完题立刻知道怎么做,然后分类讨论到吐血,写挂了,巨蠢
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std ;
int n ;
int a[] ;
int temp1,temp2 ;
int cnt1,cnt2,p1,p2 ;
int gao()
{
int f= ;
cnt1=cnt2= ;
temp1=a[]-a[] ;
for(int i= ;i<n- ;i++)
if(a[i]-a[i+]!=temp1)
{
f= ;
cnt1++ ;
p1=i ; }
temp2=a[n-]-a[n-] ;
for(int i=n- ;i>= ;i--)
if(a[i]-a[i-]!=temp2)
{
f= ;
cnt2++ ;
p2=i ;
}
if(f)
return ;
return ;
}
int main()
{
scanf("%d",&n) ;
for(int i= ;i<n ;i++)
scanf("%d",&a[i]) ;
if(n==)
{
puts("-1") ;
goto end ;
}
sort(a,a+n) ;
if(gao() && n>)
{
int d=a[]-a[] ;
if(d)
{
printf("2\n") ;
printf("%d %d\n",a[]-d,a[n-]+d) ;
}
else
{
printf("1\n") ;
printf("%d\n",a[]) ;
}
}
else if(n==)
{
if(a[]==a[])
{
printf("1\n") ;
printf("%d\n",a[]) ;
}
else
{
int d=a[]-a[] ;
if(d%==)
{
printf("3\n") ;
printf("%d %d %d\n",a[]-d,(a[]+a[])/,a[]+d) ;
}
else
{
printf("2\n") ;
printf("%d %d\n",a[]-d,a[]+d) ;
}
}
}
else if(!gao() && min(cnt1,cnt2)==)
{
if(((cnt1== && -temp1>temp2) || (cnt2== && -temp1<temp2)) && max(cnt1,cnt2)>=)
{
printf("0\n") ;
goto end ;
}
if(cnt1== && (-temp1<temp2))
{
if(a[p1]-(a[p1]+a[p1+])/==temp1 && (a[p1]+a[p1+])%==)
{
puts("") ;
printf("%d\n",(a[p1]+a[p1+])/) ;
}
else
puts("") ;
}
else
{
if(a[p2]-(a[p2]+a[p2-])/==temp2 && (a[p2]+a[p2-])%==)
{
puts("") ;
printf("%d\n",(a[p2]+a[p2-])/) ;
}
else
puts("") ;
}
}
else
puts("") ;
end :
return ;
}
CF 382C的更多相关文章
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- cf Round 613
A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...
- ARC下OC对象和CF对象之间的桥接(bridge)
在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...
- [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现
1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...
- CF memsql Start[c]UP 2.0 A
CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...
- CF memsql Start[c]UP 2.0 B
CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...
- CF #376 (Div. 2) C. dfs
1.CF #376 (Div. 2) C. Socks dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...
- CF #375 (Div. 2) D. bfs
1.CF #375 (Div. 2) D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...
随机推荐
- 解读:CombineFileInputFormat类
MR-Job默认的输入格式FileInputFormat为每一个小文件生成一个切片.CombineFileInputFormat通过将多个“小文件”合并为一个"切片"(在形成切片的 ...
- MAC OS X的命令行技巧
##透明度#降低透明度defaults write com.apple.universalaccess reduceTransparency -bool true#恢复默认透明度defaults wr ...
- CSS控制滚动条的样式
到今天(2018年10月25日)为止, 这还是chrome上的一个实验性特性: ::-webkit-scrollbar{width:4px;height:4px;} ::-webkit-scrollb ...
- Commons之Commons-io
转载自(https://my.oschina.net/u/2000201/blog/480071) 1 概述 Commons IO是针对开发IO流功能的工具类库. 主要包括六个区域: 工具类——使用 ...
- python-打印进度条
progress_bar.py #!/usr/bin/python3.6 #__*__uft8__*__ import sys import time def progress(percent,wid ...
- JAVA基础补漏--文件读取
public class Test2 { public static void main(String[] args) throws IOException { FileInputStream fis ...
- DataStage系列教程 (Slowly Changing Dimension)缓慢变化维
BI中维表的增量更新一般有2种: Type 1:覆盖更改.记录的列值发生变化,直接update成最新记录. Type 2:历史跟踪更改.记录值发生变化,将该记录置为失效,再insert一条新的记录. ...
- 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 Sum
2017-09-16 12:13:44 writer:pprp 特判 #include <iostream> using namespace std; int main() { int c ...
- Objective C NSString 编码成URL 特殊字符处理
找了一下网上的教程都是使用类似以下代码,Xcode提示这个CoreFoundation不受ARC管理,所以折中的方式是添加__bridge. NSString *encodedValue = (__b ...
- mongodb安装、运行
1.下载安装: 切换到:/usr/local/ mkdir -p mongodb groupadd -g 800 mongodb useradd -u 801 -g mongodb mongodb c ...