作为我在这个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. Python linux 上的管理工具 pyenv 安装, pip 使用, python项目(版本分割, 项目分割, 虚拟环境创建)

    01: 假设你有一个最小环境安装的 centos-6.x 的linux操作系统 02: 安装 git => yum -y install git 03: 安装依赖 => yum -y in ...

  2. leetcode149

    /* * A line is determined by two factors,say y=ax+b * * If two points(x1,y1) (x2,y2) are on the same ...

  3. element ui输入框监听enter事件

    <el-form-item label="关键字"> <el-input v-model="keywords" placeholder=&qu ...

  4. 回溯法 leetcode题解 Combination Sum 递归法

    题目大意:给出一个数组,用这些数组里的元素去凑一个target.元素可以重复取用. 感觉对这种题目还是生疏的.脑子里有想法,但是不知道怎么表达出来. 先记录下自己的递归法.应该还可以用循环实现. 回溯 ...

  5. idea 执行maven 命令

    如果当前账号不是超级管理员,这边需要执行系统用户变量, 输入安装文件bin路径 参考:https://blog.csdn.net/qq_19167629/article/details/7958490 ...

  6. Object-c 协议@protocol(@required、@optional)

    一.什么是协议? 1.协议声明了可以被任何类实现的方法2.协议不是类,它是定义了一个其他对象可以实现的接口3.如果在某个类中实现了协议中的某个方法,也就是这个类实现了那个协议.4.协议经常用来实现委托 ...

  7. IIS Express

    当前程序员只能通过下面两种web服务器之一来开发和测试ASP.NET网站程序: 1. Visual Studio自带的ASP.NET开发服务器(webdev.exe). 2. Windows自带的II ...

  8. Java学习03 (第一遍)

    Java是面向对象的语言,函数是面向过程语言的叫法,比如C语言,在Java中一般称之为方法. 构造方法的作用是实例化对象,每个类中都有,即使不写程序也会分配一个默认无参数的构造方法. Java中都是对 ...

  9. shiro 权限 URL 配置细节

  10. WinForm textbox 全选

    原地址:忘了 textBox1.KeyPress += anyTextBox_KeyPress; private void anyTextBox_KeyPress(object sender, Sys ...