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个湖,总要填掉多 ...
随机推荐
- 资源 | TensorFlow推出新工具Seedbank:即刻使用的预训练模型库【转】
本文转载自:http://tech.ifeng.com/a/20180713/45062331_0.shtml 选自TensorFlow 作者:Michael Tyka 机器之心编译 参与:路.王淑婷 ...
- LeetCode——Median of Two Sorted Arrays
Question There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median o ...
- gcc编译出错---make[5]: *** [s-attrtab] Killed
内存不足导致的编译出错,解决方法是增加swapfile. root@ubuntu:home# swapon -s Filename Type Size Used ...
- harbor 管理Helm Chart包
官方网站:https://github.com/goharbor/harbor官方用户手册:https://github.com/goharbor/harbor/blob/master/docs/us ...
- 这样获取celery的结果 有啥隐患没有啊?
- spring boot 笔记--第三章
spring boot 笔记 第三章,使用Spring boot 构建系统: 强烈建议支持依赖管理的构建系统,Maven或Gradle 依赖管理: Spring Boot的每版本都会提供它支持的依赖列 ...
- Outlook.com 系列邮箱 POP3 及 IMAP 设置方法
支持 Exchange ActiveSync 的应用 有了 EAS,你可以立即获取电子邮件,以及在一个位置查看所有文件夹.日历和联系人. 如果你的电子邮件应用支持Exchange ActiveSync ...
- 解决mac上matplotlib中文无法显示问题
系统:mac os, high sierra; python3.7(by brew installed) 在网上找了很多基本上都是让下载SimHei字体,然后放到mac的matplotlib的字体 ...
- C++名字查找和重载
重载函数的定义:在同一作用域内的几个函数名字相同但形参列表不同,称为重载函数.这里有一个重要的前提就是:同一个作用域: 而如果重载函数是定义在不同的作用域,那么一旦编译器在当前作用域找到所需的名字,编 ...
- C++11 auto类型说明符的使用
编程的时候常常需要把表达式的值赋给变量,这就要求在声明变量的时候清楚地知道表达式的类型.然而做到这一点很难,有时候根本做不到.为了解决这个问题.C++11新标准引入了auto类型说明符,用它就 能让编 ...