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;
    }
  • 相关阅读:
    MySQL索引原理
    MyBatis执行流程的各阶段介绍
    实现单栈实现支持getMin的栈
    缓存LRU算法——使用HashMap和双向链表实现
    Hystrix资源隔离
    各种负载均衡策略-图解
    接口调用超时的实现原理
    Spring Bean生命周期的各阶段介绍
    TAR命令详解 复习
    INT MOD
  • 原文地址:https://www.cnblogs.com/zufezzt/p/6294186.html
Copyright © 2011-2022 走看看