• POJ 1017 Packets 贪心 模拟


    一步一步模拟,做这种题好累

    先放大的的,然后记录剩下的空位有多少,塞1*1和2*2的进去

    //#pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<algorithm>
    #include<iostream>
    #include<sstream>
    #include<cmath>
    #include<climits>
    #include<string>
    #include<map>
    #include<queue>
    #include<vector>
    #include<stack>
    #include<set>
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int,int> pii;
    #define pb(a) push(a)
    #define INF 0x1f1f1f1f
    #define lson idx<<1,l,mid
    #define rson idx<<1|1,mid+1,r
    #define PI  3.1415926535898
    template<class T> T min(const T& a,const T& b,const T& c) {
        return min(min(a,b),min(a,c));
    }
    template<class T> T max(const T& a,const T& b,const T& c) {
        return max(max(a,b),max(a,c));
    }
    void debug() {
    #ifdef ONLINE_JUDGE
    #else
    
        freopen("in.txt","r",stdin);
        //freopen("d:\out1.txt","w",stdout);
    #endif
    }
    int getch() {
        int ch;
        while((ch=getchar())!=EOF) {
            if(ch!=' '&&ch!='
    ')return ch;
        }
        return EOF;
    }
    bool run()
    {
        int a[7];
        for(int i=1;i<=6;i++)
            cin>>a[i];
        int cnt=0;
        for(int i=1;i<=6;i++)if(a[i]!=0)cnt=1;
        if(!cnt)return 0;
    
        int res=0;
        int d1=0,d2=0;
    
        res+=a[6];
    
        res+=a[5];
        d1+=a[5]*11;
    
        res+=a[4];
        d2+=a[4]*5;
    
        res+=(a[3]+3)/4;
        if(a[3]%4!=0)
        {
            d1+=8-a[3]%4;
            d2+=7-2*(a[3]%4);
        }
    //    if(a[3]%4==1)
    //        d1+=7,d2+=5;
    //    else if(a[3]%4==2)
    //        d1+=6,d2+=3;
    //    else if(a[3]%4==3)
    //        d1+=5,d2+=1;
    //    写完发现有规律。。
    
        int x;
        x=min(a[2],d2);
        a[2]-=x;d2-=x;
        d1+=d2*4;
    
        x=min(a[1],d1);
        a[1]-=x;d1-=x;
    
        res+=(a[2]+8)/9;
        if(a[2]%9!=0)
            d1+=(9-a[2]%9)*4;
    
        x=min(a[1],d1);
        a[1]-=x;d1-=x;
    
        res+=(a[1]+35)/36;
        printf("%d
    ",res);
        return true;
    }
    int main()
    {
        std::ios::sync_with_stdio(false);
        while(run());
        return 0;
    }
    View Code
  • 相关阅读:
    小程序组件事件
    关于微信小程序中组件和页面对全局样式的继承性
    创建Java程序并设置快捷提示
    微信小程序设置全局字体
    微信小程序组件的使用
    微信开发者工具的一些快捷键
    消除flex-wrap之后每个item上下的距离
    flex布局中的主轴和侧轴的确定
    C++string中用于查找的find系列函数浅析
    C++11 图说VS2013下的引用叠加规则和模板参数类型推导规则
  • 原文地址:https://www.cnblogs.com/BMan/p/3650590.html
Copyright © 2020-2023  润新知