zoukankan      html  css  js  c++  java
  • HDU 1085

    题意:

    有1 2 5三数,你赋予他们各自的数量,求他们所不能组成的最小数

    分析:首先想到暴力,两层循环

    暴力超时,再寻他法 O(n^2)

    #include "cstdio"
    #include "cmath"
    #include "iostream"
    using namespace std;
    #define LL long long
    
    int a,b,c;
    LL solve()
    {
        int flag=0;
        for(LL i=0;;i++)
        {
            flag=0;
            for(LL j=0;j<=a&&1*j<=i;j++)
            {
                for(LL k=0;k<=b&&(1*j+2*k)<=i;k++)
                {
                    if(floor((i-j-2*k))<=c&&(i-j-2*k)%5==0)
                    {
                        flag=1;
                    }
                }
            }
            if(!flag)
                return i;
        }
    }
    int main()
    {
        while(scanf("%d%d%d",&a,&b,&c)!=EOF&&(a&&b&&c))
        {
            printf("%lld
    ",solve());
        }
    }
  • 相关阅读:
    新浪微博采用Oauth发送图片和文字
    android proguard也有弱点
    POJ 2376
    POJ 3259
    POJ 2253
    POJ 1062
    POJ 2299
    POJ 2186
    POJ 1860
    POJ 2823
  • 原文地址:https://www.cnblogs.com/kimsimple/p/6709152.html
Copyright © 2011-2022 走看看