• HDU 2277 Change the ball


    脑洞题。

    如果存在两个数字是一样的,那么有解,费用为那两个相同的数字的个数。

    也可能是如果存在两个球个数差为3 6 9 12 .. 3的倍数 也可以转,并且是转换成第三种颜色,并且转换次数是较多的那个球的个数。 
    #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<iostream>
    using namespace std;
    typedef long long LL;
    const double pi=acos(-1.0),eps=1e-6;
    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(); }
    }
    
    int Y,B,R;
    int ans[100];
    
    int main()
    {
        while(~scanf("%d%d%d",&Y,&B,&R))
        {
             for(int i=1;i<=20;i++) ans[i]=9999999;
    
             if(Y==B) ans[1]=Y;
             if(Y==R) ans[2]=R;
             if(B==R) ans[3]=B;
    
             if(Y>B&&(Y-B)%3==0) ans[4]=Y;
             if(Y>R&&(Y-R)%3==0) ans[5]=Y;
    
             if(B>Y&&(B-Y)%3==0) ans[6]=B;
             if(B>R&&(B-R)%3==0) ans[7]=B;
    
             if(R>Y&&(R-Y)%3==0) ans[8]=R;
             if(R>B&&(R-B)%3==0) ans[9]=R;
    
    
             int Ans=9999999;
             for(int i=1;i<=9;i++) Ans=min(Ans,ans[i]);
    
             if(Ans==9999999) printf("):
    ");
             else printf("%d
    ",Ans);
    
        }
        return 0;
    }
  • 相关阅读:
    2016孤独重视
    什么时候有空写一篇影评 《含泪活着》
    登录页面总结
    心跳机制
    心跳机制详解
    mysql数据库字符编码修改
    mysql20170404代码实现
    2017全面JAVA面试经历总结
    Oracle经典入门教程
    MySQL基础教程-绝对推荐
  • 原文地址:https://www.cnblogs.com/zufezzt/p/6294186.html
Copyright © 2020-2023  润新知