• CodeForces 732C Sanatorium


    分类讨论。

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

    #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
    ",min(get(A,B,C),min(get(B,C,A),get(C,A,B))));
    
        return 0;
    }
  • 相关阅读:
    作业20181127-1 附加作业 软件工程原则的应用实例分析
    20181120-1 每周例行报告
    20181113-2 每周例行报告
    获奖感言
    作业 20181030-4 每周例行报告
    20181023-3 每周例行报告
    Weekly 13
    Weekly 10
    Weekly 11
    weekly 8
  • 原文地址:https://www.cnblogs.com/zufezzt/p/6397109.html
Copyright © 2020-2023  润新知