码迷,mamicode.com
首页 > 其他好文 > 详细

CodeForces 732C Sanatorium

时间:2017-02-14 13:46:41      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:stdin   ons   int   nat   using   etc   情况   1.0   type   

分类讨论。

分几种情况讨论一下即可。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<ctime>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-10;
void File()
{
    freopen("D:\\in.txt","r",stdin);
    freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
    char c = getchar();
    x = 0;
    while(!isdigit(c)) c = getchar();
    while(isdigit(c))
    {
        x = x * 10 + c - 0;
        c = getchar();
    }
}

long long A,B,C;

long long get(long long a,long long b,long long c)
{
    long long x=min(a,min(b,c));
    a=a-x;
    b=b-x;
    c=c-x;

    if(a==0&&b==0&&c==0) return 0;
    if(a!=0&&b==0&&c==0) return (a-1)*2;
    if(a==0&&b!=0&&c==0) return (b-1)*2;
    if(a==0&&b==0&&c!=0) return (c-1)*2;


    if(a==0&&b!=0&&c!=0)
    {
        b=b-1; c=c-1;
        if(b>c) return b+b-c;
        if(b==c) return b;
        return c+c-b;
    }
    if(a!=0&&b==0&&c!=0)
    {
        if(a>c) return a-1+a-1-c;
        if(a==c) return a;
        return c+c-a;
    }
    if(a!=0&&b!=0&&c==0)
    {
        if(a>b) return a-1-b+a-1;
        if(a==b) return a-1;
        return b-1+b-a;
    }

}

int main()
{
    cin>>A>>B>>C;

    printf("%lld\n",min(get(A,B,C),min(get(B,C,A),get(C,A,B))));

    return 0;
}

 

CodeForces 732C Sanatorium

标签:stdin   ons   int   nat   using   etc   情况   1.0   type   

原文地址:http://www.cnblogs.com/zufezzt/p/6397109.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!