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 ...
随机推荐
- [AtCoder3954]Painting Machines
https://www.zybuluo.com/ysner/note/1230961 题面 有\(n\)个物品和\(n-1\)台机器,第\(i\)台机器会为第\(i\)和\(i+1\)个物品染色.设有 ...
- DCloud-MUI:窗口管理
ylbtech-DCloud-MUI:窗口管理 通过预加载解决切页白屏问题,通过封装原生动画解决SPA模式的动画卡顿 1.返回顶部 1.页面初始化 在app开发中,若要使用HTML5+扩展api,必须 ...
- sublime 的快捷键大全
Sublime Text 3 快捷键精华版 Ctrl+Shift+P:打开命令面板 Ctrl+P:搜索项目中的文件 Ctrl+G:跳转到第几行 Ctrl+W:关闭当前打开文件 Ctrl+Shift+W ...
- mybatis+oracle实现一对多,多对一查询
首先创建表 学生表 create table stu( id number(11) primary key, name varchar2(255), age num ...
- 基于移动Web的视图引擎实现
第一步:移动视图引擎实现 using System.Web.Mvc; /// <summary> /// 移动版View引擎 /// </summary> public cla ...
- 简单ajax库
function TuziAjax(reqType,url,fnoK, fnFail) { var xmlHttp = null; if (window.XMLHttpRequest) { xmlHt ...
- Android 存储路径选择
Android能用来存储的地方有两个,一个是手机内置的存储空间,一个是外置的SD卡,内置的存储空间一般比较小,所以应用的缓存建议存储在外置的SD卡中. 在Android系统中如何获得存储的路径呢? p ...
- 【Android】实例 忐忑的精灵
在Android Studio中创建项目,名称为“Animation And Multimedia”,然后在该项目中创建一个Module,名称为“Frame-By-Frame Animation”.在 ...
- ROS:使用ubuntuKylin17.04安装ROS赤xi龟
使用ubuntuKylin17.04安装 参考了此篇文章:SLAM: Ubuntu16.04安装ROS-kinetic 重复官方链接的步骤也没有成功. 此后发现4.10的内核,不能使用Kinetic. ...
- MFC和OpenCV结合
最重要的一点:如何把OpenCV的框嵌入MFC的ID.. 把cv显示框嵌入 pic控件 cvNamedWindow("kalman"); HWND hWnd = (HWND) cv ...