e-olymp Problem8352 Taxi
作为我在这个OJ玩了一下午的终结吧。
水题一道,阅读理解OJ。
传送门:点我
Taxi
At the peak hour, three taxi buses drove up at the same time, following one route, where the passengers immediately got crowded. The drivers found that the number of people in taxis is different, so they decided to relocate a part of passengers so that in each minibus there will be an equal number of passengers. Determine what is the fewest number of passengers have to be relocated at the same time.
Input
Three integers not greater than 100 - the number of passengers in the first, second and third taxi bus.
Output
Print one number - the minimum number of passengers that must be relocated. If its not possible, print the word IMPOSSIBLE (with capital letters).
1 2 3
1 题意:给定三个数,如果能均分那么输出最小的挪动个数,如果不能则输出IMPOSSIBLE。
样例解释:1 2 3,把3挪一个到1,那么就变成了2 2 2,即均分。
思路:如果和余3不等0,那么肯定不行。
如果和余3等于0,直接看代码吧。。。。
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset> using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define pill pair<int, int>
#define REP(i, x, n) for(int i = x; i <= n; ++i)
int Scan()
{
int res = , ch, flag = ;
if((ch = getchar()) == '-')
flag = ;
else if(ch >= '' && ch <= '')
res = ch - '';
while((ch = getchar()) >= '' && ch <= '' )
res = res * + ch - '';
return flag ? -res : res;
}
int main(){
int x,a[];
cin>>a[]>>a[]>>a[];
int sum = a[]+a[]+a[];
if(sum % != ){
puts("IMPOSSIBLE");
}else{
sum = sum/;
int ans = ;
for(int i = ; i < ; i++){
if(a[i] < sum) ans+=(sum-a[i]);
}
printf("%d\n",ans);
}
}
e-olymp Problem8352 Taxi的更多相关文章
- 【HDU1960】Taxi Cab Scheme(最小路径覆盖)
Taxi Cab Scheme Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- A cost-effective recommender system for taxi drivers
一个针对出租车司机有效花费的推荐系统 摘要 GPS技术和新形式的城市地理学改变了手机服务的形式.比如说,丰富的出租车GPS轨迹使得出做租车领域有新方法.事实上,最近很多工作是在使用出租车GPS轨迹数据 ...
- poj 2060 Taxi Cab Scheme (二分匹配)
Taxi Cab Scheme Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5710 Accepted: 2393 D ...
- [ACM_数学] Taxi Fare [新旧出租车费差 水 分段函数]
Description Last September, Hangzhou raised the taxi fares. The original flag-down fare in Hangzhou ...
- zjuoj 3600 Taxi Fare
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3600 Taxi Fare Time Limit: 2 Seconds ...
- Taxi Trip Time Winners' Interview: 3rd place, BlueTaxi
Taxi Trip Time Winners' Interview: 3rd place, BlueTaxi This spring, Kaggle hosted two competitions w ...
- poj 2060 Taxi Cab Scheme (最小路径覆盖)
http://poj.org/problem?id=2060 Taxi Cab Scheme Time Limit: 1000MS Memory Limit: 30000K Total Submi ...
- The 9th Zhejiang Provincial Collegiate Programming Contest->Problem A:A - Taxi Fare
Problem A: Taxi Fare Time Limit: 2 Seconds Memory Limit: 65536 KB Last September, Hangzhou raised th ...
- Taxi Cab Scheme POJ && HDU
Online Judge Problem Set Authors Online Contests User Web Board Home Page F.A.Qs Statistical Charts ...
随机推荐
- jsp grid can not be used in this ('quirks') mode
设置: <!--设置IE文档模式 --> <meta http-equiv="X-UA-Compatible" content="IE=9" ...
- 【ASP.NET 进阶】PDF文件在线预览(类似百度文库)
工作需要完成文档的在线预览,现在完成了第一步PDF文件的预览,步骤是通过PDF转换工具pdf2swf.exe把PDF文件转换为SWF文件,然后通过FlexPaper就可以预览了.效果如下(GIF图片太 ...
- Spring Cloud (6)A config 服务端配置 与github通信
1. 在git上创建一个库,并复制库地址 2.用git clone项目到本地,并创建application.yml application.yml 内容 --下一步 3.将application.ym ...
- java的原子类 AtomicInteger 实现原理是什么?
采用硬件提供原子操作指令实现的,即CAS.每次调用都会先判断预期的值是否符合,才进行写操作,保证数据安全. CAS机制 CAS是英文单词Compare And Swap的缩写,翻译过来就是比较并替换. ...
- day19-高阶函数、匿名函数
map 函数 map 是一个在 Python 里非常有用的高阶函数.它接受一个函数和一个序列(迭代器)作为输入,然后对序列(迭代器)的每一个值应用这个函数,返回一个序列(迭代器),其包含应用函数后的结 ...
- mingw编译ffmpeg 错误:Unknown option "--enable-memalign-hack"
据说mingw编译ffmpeg的话需要添加 --enable-memalign-hack 开关 但如果源码是最新版比如:ffmpeg4.0.2 的话 好像已经禁用了该开关. “我可以确认新的ffmpe ...
- es6初级之箭头函数实现隔行变色
无论是使用哪种方式实现隔行变色的效果,它的思路都是一样的: 1.定义很多个div 2.给div 加背景 3.鼠标移动到div上时,当前div 背景变色 4.鼠标移出div时,当前div背景恢复 以上4 ...
- Haskell语言学习笔记(91)Comprehension Extensions
Comprehension Extensions 关于解析式的相关语言扩展. List and Comprehension Extensions 24 Days of GHC Extensions: ...
- Haskell语言学习笔记(81)Data.Typeable
Data.Typeable 利用 Data.Typeable,可以打印动态类型信息. class Typeable (a :: k) where typeRep# :: TypeRep a typeR ...
- su: cannot set user id: Resource temporarily unavailable问题解决
操作环境 SuSE11sp1 问题现象 执行su - test命令切换失败,提示"su: cannot set user id: Resource temporarily unavailab ...