• 2017 Multi-University Training Contest


    2017 Multi-University Training Contest - Team 7

    08  /  hdu6127    枚举

    #include<bits/stdc++.h>
    using namespace std;
    #pragma comment(linker, "/STACK:102400000,102400000")
    #define rep(i,a,b) for (int i=a; i<=b; ++i)
    #define per(i,b,a) for (int i=b; i>=a; --i)
    #define mes(a,b)  memset(a,b,sizeof(a))
    #define INF 0x3f3f3f3f
    #define MP make_pair
    #define PB push_back
    #define fi  first
    #define se  second
    typedef long long ll;
    const int N = 50005;
    
    struct P {
        double rat, x, y; ll val;
        friend bool operator < (P a, P b) {
            return a.rat<b.rat;
        }
    }p[N], p1;
    int n;
    int main()
    {
        int T;  scanf("%d", &T);
        while(T--)
        {
            scanf("%d", &n);
            int tot=0;
            ll  cnt1=0, cnt2=0, ans=0;
            p1 = {0,0,0,0};
            double xi, yi;   ll  val;
            rep(i,1,n)
            {
                scanf("%lf%lf%lld", &xi, &yi, &val);
                if(xi==0)  p1={0,xi,yi,val};
                else {
                    p[++tot]={yi/xi,xi,yi,val};
                    xi<0 ? cnt1+=val : cnt2+=val;
                }
            }
            if(p1.val) {
                ans = max(ans, max((cnt1+p1.val)*cnt2 , cnt1*(cnt2+p1.val)) );
                cnt2 += p1.val;
            }
            sort(p+1, p+1+tot);
            rep(i,1,tot)
            {
                if(p[i].x<0) cnt1 -= p[i].val,  cnt2 += p[i].val;
                else  cnt1 += p[i].val, cnt2 -= p[i].val;
                ans = max(ans, cnt1*cnt2);
            }
            printf("%lld
    ", ans);
        }
    
        return 0;
    }

    11   /  hdu6130     打表

    #include<bits/stdc++.h>
    using namespace std;
    #pragma comment(linker, "/STACK:102400000,102400000")
    #define rep(i,a,b) for (int i=a; i<=b; ++i)
    #define per(i,b,a) for (int i=b; i>=a; --i)
    #define mes(a,b)  memset(a,b,sizeof(a))
    #define INF 0x3f3f3f3f
    #define MP make_pair
    #define PB push_back
    #define fi  first
    #define se  second
    typedef long long ll;
    const int N = 10000005;
    
    int n, a[N];
    void Init()
    {
        int len=1, pre=1, now;
        a[1]=1, a[2]=2;
        rep(ca,2,N-1)
        {
            if(len>=10000000) break;
            now = 1+(pre==1);
            rep(i,1,a[ca]) a[++len]=now;
            pre=now;
        }
    }
    int main()
    {
        Init();
        int T;  scanf("%d", &T);
        while(T--)
        {
            scanf("%d", &n);
            printf("%d
    ", a[n]);
        }
    
        return 0;
    }
  • 相关阅读:
    雨中梦游
    最后一次为你哭
    poj3169 Layout
    poj2253 Frogger
    钟爱一生
    POJ2668解题报告
    魅力泸西
    android学习笔记09(activity的生命周期)
    poj 3468 A Simple Problem with Integers
    android学习笔记之多线程(二)
  • 原文地址:https://www.cnblogs.com/sbfhy/p/7372185.html
Copyright © 2020-2023  润新知