hdoj_5174题Ferries Wheel
来源:互联网 发布:唐泽寿明 知乎 编辑:程序博客网 时间:2024/06/05 15:27
Problem Description
The Ferries Wheel is a circle,rounded by many cable cars,and the cars are numbered
Today,Misaki invites
Please help Misaki to calculate how many kisses she will pay,you can assume that there is no empty cable car when all friends enter their cable cars,and one car has more than one friends is valid.
Input
There are many test cases.
For each case,the first line is a integer
The INT_MAX is
Output
Sample Input
3
1 2 3
5
1 2 3 5 7
6
2 3 1 2 7 5
Sample Output
Case #1: 1
Case #2: 2
Case #3: 3
这个题目带坑的一点是一个car里可以有几个小朋友,不过这也不算什么,基本就是暴力,还有要注意就是INT_MAX is
上代码
#include <iostream>#include<stdio.h>#include<algorithm>using namespace std;class car{public: long long int v; int ct;};long long int person[110];long long int maxint=2147483647;int n,k,cs;int main(){ cs=1; while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++) { scanf("%I64d",&person[i]); } sort(person,person+n); car cars[110]; k=0; for(int i=0;i<n;i++) { if(i==0&&k==0) { cars[k].v=person[i]; cars[k].ct=1; k++; }else { if(person[i]==cars[k-1].v) { cars[k-1].ct++; }else { cars[k].v=person[i]; cars[k].ct=1; k++; } } } if(k==1) { printf("Case #%d: -1\n",cs); }else { int cnt=0; for(int i=0;i<k;i++) { if((cars[((i-1+2*k)%k)].v+cars[i].v)%maxint==cars[(i+1)%k].v) { cnt+=cars[i].ct; } } printf("Case #%d: %d\n",cs,cnt); } cs++; } //cout << "Hello world!" << endl; return 0;}
- hdoj_5174题Ferries Wheel
- hdu5174---Ferries Wheel
- HDU 5174 Ferries Wheel
- 【BestCoder】 HDOJ 5174 Ferries Wheel
- HDU 5174 Ferries Wheel (暴力小模拟)
- Hdu 5174 Ferries Wheel(模拟)
- Valentine's Day Round 1001 Ferries Wheel
- HDU—— 5174 Ferries Wheel
- hdu 5174 Ferries Wheel(模拟)
- [Bestcoder] Valentine's Day Round 1001 - Ferries Wheel | HDU 5174
- hdu5174 Ferries Wheel (暴力求解也是有艺术的)
- hdu 5174 Ferries Wheel【模拟】【排序+去重】
- HDU 5147 Ferries Wheel(暴力 数组)——BestCoder Valentine's Day Round
- 【CUGBACM15级BC第30场 A】hdu 5174 Ferries Wheel
- wheel
- 2015年某wheel笔试题(未)
- 1014 bridge ferries
- SPOKES WHEEL
- 国内外SNS比较分析
- 马云的这番话 造就了无数的富翁
- 凤凰网:淘宝叫板工商总局,阿里巴巴市值一夜蒸发680亿
- 黑马程序员---从头开始,回忆JAVA基础之集合(二)
- curl引起的截断问题
- hdoj_5174题Ferries Wheel
- 关于ASP.Net MVC 强类型视图
- @property 下 strong weak copy assign
- 欢迎使用CSDN-markdown编辑器
- leetcode Multiply Strings
- curl提示failed creating formpost data
- Magic Square
- Android之Button自定义点击效果
- Joomla使用ajax.googleapis.com导致网页加载非常慢的解决方法