题意有点不明白,因为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的更多相关文章

  1. 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] ...

  2. hdu 5174(计数)

    Ferries Wheel Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  3. hdu 5174 Ferries Wheel

    摩天轮是一个环,周围围绕着一些缆车.每个缆车按顺序编号为1,2,3...K-1,K1,2,3...K−1,K而且每个缆车也拥有一个唯一的值且保证A[i-1] < A[i] < A[i+1] ...

  4. BestCoder Valentine's Day Round

    昨晚在开赛前5分钟注册的,然后比赛刚开始就掉线我就不想说了(蹭网的下场……),只好用手机来看题和提交,代码用电脑打好再拉进手机的(是在傻傻地用手机打了一半后才想到的办法). 1001,也就是 hdu ...

  5. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  6. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  7. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  8. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  9. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

随机推荐

  1. P1993 小K的农场 差分约束系统

    这个题是一道差分约束系统的裸题,什么是差分约束系统呢?就是给了一些大小条件,然后让你找一个满足的图.这时就要用差分约束了. 怎么做呢?其实很简单,就是直接建图就好,但是要把所有条件变为小于等于号,假如 ...

  2. gdb 断点调试C程序

    最近在看CS50的公开课,视频中david用gdb调试C,我跟着敲,一样的代码但是却显示效果与他不一样.因为他的程序是编译好了的,所以也没看到编译步骤,后来回想一下他make 文件名 显示的代码中有一 ...

  3. com/opensymphony/xwork2/spring/SpringObjectFactory.java:220:-1问题出现的原因及解决办法

    转自:https://blog.csdn.net/shinchan_/article/details/37818927 com/opensymphony/xwork2/spring/SpringObj ...

  4. python mysql数据库 'latin-1' codec can't encode character错误问题解决

    "UnicodeEncodeError:'latin-1' codec can't encode character ..."     This is because MySQLd ...

  5. ul和li里面的list-style

    对ul   list-type  只是设置ul的样式对li    list-type 是对li的综合样式设定  语法是 li-style:list-style-type/list-style-imag ...

  6. Python-控制流

    if #!/usr/bin/python number=23 guess=int(input('Enter an interger:')) #input返回的结果是string类型,需要用int()转 ...

  7. Spring boot (12) tomcat jdbc连接池

    默认连接池 tomcat jdbc是从tomcat7开始推出的一个连接池,相比老的dbcp连接池要优秀很多,spring boot将tomcat jdbc作为默认的连接池,只要在pom.xml中引入了 ...

  8. Java中last_insert_id的使用

    last_insert_id的作用是:在当前表中的主键是自增时,插入一条新记录的同时使用last_insert_id可以获取当前的新记录的主键id. 下面是一个例子: import java.sql. ...

  9. WEB笔记-5、字体和文本

    字体样式 font-family font-size font-weight font-style font-variant font(简写) 常用字体: serif,衬线字体,每个字符笔画末端会有装 ...

  10. 连接SQL Server数据库语法

    下面介绍一下连接Sqlserver数据库.把连接Sqlserver数据库封装为一个方法,以便直接调用,而不需写重复代码. import java.sql.Connection; import java ...