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 ...
 
随机推荐
- selenium3 + python - gird分布式(转载)
			
本篇转自博客:上海-小T 转载链接:https://blog.csdn.net/real_tino/article/details/53467406 Selenium grid是用来分布式执行测试用例 ...
 - 【原创分析帖】据说Google内部有史以来最难的一道面试题
			
逛技术平台的时候,刷到一道算法题,一眼看去,就被其开头吸引了: 摘自知乎某 Google 分布式大神的一道题,技术是Google内部出的有史以来最难的一道题 嗯,距离下班还有一段时间,就看看把. 题目 ...
 - 【寒假集训系列DAY3】
			
DAY2的坑之后会补上 DAY3 今天暴力分拿的还是不错的...60+30+25=115,但还是太弱了呀,每题都只会暴力(话说第3题直接输-1给了15分,本以为只会给5分,然后打了半个小时的爆搜... ...
 - POJ 1111(数字很吉利嘛)  简单BFS
			
Image Perimeters Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8594 Accepted: 5145 Desc ...
 - POJ 3635 优先队列BFS
			
(感谢lyd学长的幻灯片) 注意vis数组的应用 在vis[i][j]中 i表示到了第i个点 j表示还剩j升油 vis[i][j]表示最小话费. 这样只需搜到话费比它少的更新入堆就OK了 //By: ...
 - C#之考勤系统
			
闲来无聊,搞搞C#,下面就是我写的一个Demo 员工类 using System; using System.Collections.Generic; using System.Linq; using ...
 - # --with-http_random_index_module模块
			
作用: 从目录中随机选取一个随机作为主业 环境 nginx -V 检测是否已经安装了该模块 语法 案例 在/usr/share/nginx下随机创建3个html文件 修改配置文件
 - Java中Ajaxa中文乱码问题
			
客户端: url='test/queryList?itemName='+itemName; //如果只转一次url=encodeURI(toUrl); 到后台时:乱码 servlet里dec ...
 - SQLServer2008 去除换行符
			
declare @str varchar(8000)set @str='SQL语句' select replace(@str,char(10),'')
 - PostgreSQL的HA解决方案-1主从和备份(master/slave and backup)
			
一.部署说明 1.1 实施环境 本文档实验环境如下: PGSQL主机: 192.168.1.45 PGSQL备机: 192.168.1.50 软件和系统版本 Pgsql 版本: pgsql 9.2.4 ...