zoukankan      html  css  js  c++  java
  • Nordic Collegiate Programming Contest (NCPC) 2016

    A Artwork


    B Bless You Autocorrect!


    C Card Hand Sorting


    D Daydreaming Stockbroker

    贪心,低买高卖,不要爆int。

    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <iostream>
    
    using namespace std;
    typedef long long LL;
    const int maxn=400;
    const int INF=2147000000;
    LL p[maxn];
    int d,n;
    LL mo,sh;
    int main(){
        scanf("%d",&d);
        LL a,num=0;
        for(int i=1;i<=d;i++){
            scanf("%lld",&a);
            if(a!=p[num]){
                num++;
                p[num]=a;
            }
        }
        d=num;
        p[0]=INF,p[d+1]=-INF;
        mo=100,sh=0;
        for(int i=1;i<=d;i++){
            if(p[i]<p[i-1]&&p[i]<p[i+1]&&mo>=p[i]){
                LL num=mo/p[i];
                if(num>100000){
                    sh+=100000;
                    mo-=p[i]*100000;
                }else{
                    sh+=num;
                    mo-=p[i]*num;
                }
            }
            if(p[i]>p[i-1]&&p[i]>p[i+1]&&sh){
                mo+=p[i]*sh;
                sh=0;
            }
        }
    
        printf("%lld
    ",mo);
    return 0;
    }
    


    E Exponial


    F Fleecing the Raffle


    G Game Rank

    炉石传说的rank机制。直接模拟就好。

    #include <bits/stdc++.h>
    using namespace std;
    const int maxn = 10010;
    int up(int x)
    {
        if (x >= 21) return 2;
        if (x >= 16) return 3;
        if (x >= 11) return 4;
        if (x >= 1) return 5;
        return 0x3f3f3f3f;
    }
    
    int main()
    {
        char s[maxn];
        scanf("%s", s);
    
        int tmp = 0;
        int rak = 25, star = 0;
        for (int i = 0; s[i]; i++)
        {
            if (s[i] == 'W')
            {
                ++tmp, ++star;
                if (tmp >= 3 && rak > 5) star++;
            }
            else
            {
                if ((rak > 0 && rak < 20) || (rak == 20 && star)) star--;
                tmp = 0;
            }
    
            if (star > up(rak))
            {
                star -= up(rak);
                rak--;
            }
    
            if (star < 0)
            {
                rak++;
                star = up(rak)-1;
            }
        }
    
        if (rak < 1) printf("Legend
    ");
            else printf("%d
    ", rak);
    
        return 0;
    }
    

     
    H Highest Tower


    I Interception


    J Jumbled Compass

    签到

    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    
    using namespace std;
    
    int n1,n2;
    int main(){
        scanf("%d%d",&n1,&n2);
        int a1 = n1-n2;
        int a2 = 360-abs(a1);
        if(a1 > 0) {
            if(a1 >= 180) printf("%d
    ", a2);
            else printf("-%d", abs(a1));
        }
        else {
            if(abs(a1) > 180) printf("-%d
    ", a2);
            else printf("%d", abs(a1));
        }
    return 0;
    }
    


    K Keeping the Dogs Apart

  • 相关阅读:
    PHP 动态执行
    jenkins 'cordova' command not recognised on Jenkins Windows slave
    ionic3 实现扫码功能
    解决ionic3 android 运行出现Application Error
    解决添加codova plugin 编译出现问题:Execution failed for task ':processDebugManifest'.
    菜鸟的 Sass 学习笔记
    解决关于ios访问相机闪退问题
    解决ios关于:ERROR Internal navigation rejected
    Angular4 组件通讯方法大全
    ASP.NET MVC5 使用MiniProfiler 监控MVC性能
  • 原文地址:https://www.cnblogs.com/ruthank/p/9768151.html
Copyright © 2011-2022 走看看