HDU 5174
题意有点不明白,因为MAX为int最大值,推测为64位,AC
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cctype>
#include <algorithm>
#define LL __int64
using namespace std;
const LL MAX=2147483647;
const int N=110;
LL friends[N];
int n;LL tot;
struct Node{
LL v,c;
}node[N];
bool cmp(LL a,LL b){
if(a<b) return true;
return false;
}
int main(){
int t=0;
while(scanf("%d",&n)!=EOF){
tot=-1;
for(int i=0;i<n;i++){
scanf("%I64d",&friends[i]);
node[i].c=0;
}
sort(friends,friends+n,cmp);
for(int i=0;i<n;i++){
if(i==0||friends[i]!=friends[i-1]){
node[++tot].v=friends[i];
node[tot].c++;
}
else if(friends[i]==friends[i-1])
node[tot].c++;
}
if(tot==0){
printf("Case #%d: -1\n",++t);
continue;
}
LL now,le,rig; tot++;
LL ans=0;
for(LL i=0;i<tot;i++){
now=i;
le=((i-1)%tot+tot)%tot,rig=((i+1)%tot+tot)%tot;
if((node[now].v+node[le].v)%MAX==node[rig].v)
ans+=node[now].c;
}
printf("Case #%d: %I64d\n",++t,ans);
}
return 0;
}
HDU 5174的更多相关文章
- Valentine's Day Round 1001.Ferries Wheel(hdu 5174)解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5174 题目意思:给出 n 个人坐的缆车值,假设有 k 个缆车,缆车值 A[i] 需要满足:A[i−1] ...
- hdu 5174(计数)
Ferries Wheel Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- hdu 5174 Ferries Wheel
摩天轮是一个环,周围围绕着一些缆车.每个缆车按顺序编号为1,2,3...K-1,K1,2,3...K−1,K而且每个缆车也拥有一个唯一的值且保证A[i-1] < A[i] < A[i+1] ...
- BestCoder Valentine's Day Round
昨晚在开赛前5分钟注册的,然后比赛刚开始就掉线我就不想说了(蹭网的下场……),只好用手机来看题和提交,代码用电脑打好再拉进手机的(是在傻傻地用手机打了一半后才想到的办法). 1001,也就是 hdu ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
随机推荐
- 多线程编程和Java网络编程
1. 线程概述 多任务处理有两种类型:基于进程.基于线程(进程是指一种“自包容”的运行程序,有自己的地址空间; 线程是进程内部单一的一个顺序控制流) 基于进程的特点是允许计算机同时运行两个或更多的程序 ...
- PCB 全景图技术实现
为了对3D模型理解更透,这里采用threejs(WebGL第三方库)实现,刚开始学习入门,为了能看明白基本上每行代码都注释. 如果仅仅是为了实现全景图,可以用photo-sphere-viewer.j ...
- jq中append()、prepend()、after()、before()的区别
jq中append().prepend().after().before()的区别详解 .append() - 在被选元素的结尾插入内容(内容的结尾,比如说有个a标签,则是在</a>这个标 ...
- Django之ORM的增删改查操作流程
总结:ORM的 查.增.删.改 - 查 - client - 有一个展示页面(xxx_show.html) - 这一个页面一输入执行后,get请求向server端发送 - 这个展示页面有添加按钮.删除 ...
- C - Lucky Numbers (easy)
Problem description Petya loves lucky numbers. Everybody knows that positive integers are lucky if t ...
- Hibernate多表查询、查询优化策略(四)
多表HQL private static void innerJoin(){ //sql内连接 隐式内连接 select * from A,B where b.aid = a.id // 显示内连接 ...
- jquery中的left和top
left 和 top /*1. 获取元素基于定位容器的位置*/ /*返回的是对象 属性 left top */ var position = $('.inner').position(); conso ...
- angular js shopping
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- 努比亚 N2(Nubia NX575J) 解锁BootLoader 并进入临时recovery ROOT
工具下载链接:https://pan.baidu.com/s/1jJoK2Yq 备用下载链接:https://pan.baidu.com/s/1snjwLdz 密码:71rg 本篇教程教你如何傻瓜式解 ...
- 图片懒加载插件echo.js——改造
今天做一个列表项需要用到懒加载,搜到网友推荐的echo.js,试用了一下,还不错.除了懒加载,还提供了throttle——节流,即用户快速滑动列表时,很快滑过的项的图片不会加载,只会加载最后停下来的位 ...