作为我在这个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).

Time limit 1 second
Memory limit 128 MiB
Input example #1
1 2 3
Output example #1
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的更多相关文章

  1. 【HDU1960】Taxi Cab Scheme(最小路径覆盖)

    Taxi Cab Scheme Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  2. A cost-effective recommender system for taxi drivers

    一个针对出租车司机有效花费的推荐系统 摘要 GPS技术和新形式的城市地理学改变了手机服务的形式.比如说,丰富的出租车GPS轨迹使得出做租车领域有新方法.事实上,最近很多工作是在使用出租车GPS轨迹数据 ...

  3. poj 2060 Taxi Cab Scheme (二分匹配)

    Taxi Cab Scheme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5710   Accepted: 2393 D ...

  4. [ACM_数学] Taxi Fare [新旧出租车费差 水 分段函数]

    Description Last September, Hangzhou raised the taxi fares. The original flag-down fare in Hangzhou ...

  5. zjuoj 3600 Taxi Fare

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3600 Taxi Fare Time Limit: 2 Seconds    ...

  6. Taxi Trip Time Winners' Interview: 3rd place, BlueTaxi

    Taxi Trip Time Winners' Interview: 3rd place, BlueTaxi This spring, Kaggle hosted two competitions w ...

  7. poj 2060 Taxi Cab Scheme (最小路径覆盖)

    http://poj.org/problem?id=2060 Taxi Cab Scheme Time Limit: 1000MS   Memory Limit: 30000K Total Submi ...

  8. 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 ...

  9. Taxi Cab Scheme POJ && HDU

    Online Judge Problem Set Authors Online Contests User Web Board Home Page F.A.Qs Statistical Charts ...

随机推荐

  1. Shell 编程(实例一)

    创建一个脚本 admin.sh 完成如下作用: -h | --help : 提供帮助信息 --add  Users : 完成用户添加 -del User | --delete : 完成用户删除 -v ...

  2. python内置函数使用

    print(abs(1)) #绝对值,正数就是自己 ",''])) #计算可迭代对象中是否为真,其中一个为假,就显示为假 print(all('')) # If the iterable i ...

  3. VC中链接错误,提示string重定义

    VC链接错误,说是string已经有了实现了,只要 rebuild 一下好了. Linking...LINK : warning LNK4075: ignoring '/EDITANDCONTINUE ...

  4. [uwsgi: command not found]

    问题: pip install uwsgi 之后,运行uwsgi 报错:[uwsgi: command not found] 解决方案:建立软链接 ln -s /usr/local/python3/b ...

  5. Python集合的基本操作

    #-*coding:utf-8 -* list =set([2,3,4]) list2 =set([5,3,7]) #交集 #print (list.intersection(list2)) #并集 ...

  6. byobu session window split

    new session:  Ctrl + Shift + F2 window: F2 split: Shift/Ctrl + F2 move session: Alt + Up/Down window ...

  7. 使用pt-table-checksum及pt-table-sync校验复制一致性

    一.简介 pt-table-checksum是percona-toolkit系列工具中的一个, 可以用来检测主. 从数据库中数据的一致性.其原理是在主库上运行, 对同步的表进行checksum, 记录 ...

  8. git使用——分支

    创建dev分支,并切换到dev分支. git checkout -b dev //Switched to a new branch 'dev' 查看分支. git branch //* dev &qu ...

  9. C#使用MonoPInvokeCallback,让C直接回调C#函数

    Test.mm char* TestMakeCString(NSString *str) { const char* string = [str UTF8String]; if (string == ...

  10. 【369】列表/字典的分拆, unpacking

    参考: python--参数列表的分拆 参考: List Comprehensions 当你要传递的参数已经是一个列表,调用的函数却接受分开一个个的参数,这个时候可以考虑参数列表拆分: 可以使用* 操 ...