zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    第四章 分布式扩展
    第三章 2.性能压测,容量问题
    第三章 1.云部署,打包上传
    MySQL语法大全
    Python随手记
    Python操作Mysql中文乱码问题
    Python基础函数
    破解电信校园网路由限制
    ThinkPHP扩展函数的三个方法
    $_SERVERS预定义变量
  • 原文地址:https://www.cnblogs.com/zufezzt/p/6294186.html
Copyright © 2011-2022 走看看