zoukankan      html  css  js  c++  java
  • CodeForces Round #569 Div.2

    A. Alex and a Rhombus

    #include <bits/stdc++.h>
    using namespace std;
     
    int num[110];
    int N;
     
    int main() {
        memset(num, 0, sizeof(num));
        num[0] = 0, num[1] = 1;
        for(int i = 2; i <= 100; i ++)
            num[i] = num[i - 1] + 4 * (i - 1);
     
        scanf("%d", &N);
        printf("%d
    ", num[N]);
     
        return 0;
    }
    View Code

    B. Nick and Array

    #include <bits/stdc++.h>
    using namespace std;
     
    const int maxn = 1e5 + 10;
    int N;
    int a[maxn];
     
    int main() {
        scanf("%d", &N);
        for(int i = 0; i < N; i ++) {
            scanf("%d", &a[i]);
            if(a[i] >= 0) a[i] = -1 * a[i] - 1;
        }
        if(N % 2) {
            int minn = -1, temp = 0;
            for(int i = 0; i < N; i ++) {
                if(a[i] < minn) {
                    minn = a[i];
                    temp = i;
                }
            }
            if(minn == -1) a[0] = 0;
            else a[temp] = -1 * a[temp] - 1;
        }
     
        for(int i = 0; i < N; i ++)
            printf("%d%s", a[i], i == N - 1 ? "
    " : " ");
        return 0;
    }
    View Code

    C. Valeriy and Deque

    By Golden_miner, contest: Codeforces Round #569 (Div. 2), problem: (C) Valeriy and Deque, Accepted, #, Copy
    #include <bits/stdc++.h>
    using namespace std;
     
    const int maxn = 1e5 + 10;
    int N, Q;
    deque<int> q;
    vector<pair<int, int> >v;
     
    int main() {
        scanf("%d%d", &N, &Q);
        int maxx = -1, temp = 0;
        for(int i = 1; i <= N; i ++) {
            int x;
            scanf("%d", &x);
            maxx = max(maxx, x);
            q.push_back(x);
        }
     
        int top = q.front();
        while(top != maxx) {
            pair<int, int> p;
            p.first = q.front(); q.pop_front();
            p.second = q.front(); q.pop_front();
            v.push_back(p);
            q.push_front(max(p.first, p.second));
            q.push_back(min(p.first, p.second));
            top = q.front();
        }
     
        q.pop_front();
        int sz = v.size();
     
        deque<int>::iterator it = q.begin();
        for(it = q.begin(); it != q.end(); it ++) {
            pair<int, int> p;
            p.first = top, p.second = *it;
            v.push_back(p);
        }
     
        while(Q --) {
            long long tim;
            scanf("%lld", &tim);
            if(tim <= sz) printf("%d %d
    ", v[tim - 1].first, v[tim - 1].second);
            else {
                tim -= sz;
                tim %= (v.size() - sz);
                tim = (tim % (v.size() - sz) == 0) ? v.size() - sz : tim % (v.size() - sz);
                printf("%d %d
    ", v[tim + sz - 1].first, v[tim + sz - 1].second);
            }
        }
     
        return 0;
    }
    View Code

    D. Tolik and His Uncle

    #include <bits/stdc++.h>
    using namespace std;
    
    int N, M;
    
    int main() {
        scanf("%d%d", &N, &M);
        int x = 1, y = 1;
        int dx = N, dy = M;
        int cnt = 0;
        
        while(cnt != N * M) {
            if(cnt == N * M - 1) {
                printf("%d %d
    ", x, y);
                break;
            }
    
            printf("%d %d
    %d %d
    ", x, y, dx, dy);
    
            if(y < M) y ++;
            else {
                x ++;
                y = 1;
            }
    
            if(dy > 1) dy --;
            else {
                dx --;
                dy = M;
            }
    
            cnt += 2;
        }
        return 0;
    }
    View Code

    APP 开发算是中场休息辣!我终于终于更题目了 呜呜呜

  • 相关阅读:
    Run keyword if
    sublime Text如何取消两栏窗口?
    WIN7右键在目录当前打开命令行Cmd窗口
    电脑用HDMI线分屏后,耳机或音箱没声音之完美解决!
    如何解决failed to load the jni shared library问题
    APP测试点
    PHP 根据ip判断其所属地址
    thinkPHP git上传的时候,总是有些文件传不上去,.gitignore解析
    Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous
    tp5导出生成pdf
  • 原文地址:https://www.cnblogs.com/zlrrrr/p/12802287.html
Copyright © 2011-2022 走看看