首页 > 其他 > 详细

cfER 609div2

时间:2020-01-03 09:45:49      阅读:75      评论:0      收藏:0      [点我收藏+]

传送门

 


 


A    Equation standard input/output 3 s, 256 MB Submit Add to favourites x8521

  手推一下, 把 1 2 单独输出, 其他奇数输出  3*n 2*n  偶数则输出 4*n  2*n
B    Modulo Equality standard input/output 3 s, 256 MB Submit Add to favourites x4481

  枚举一下 (b[0]-a[i]+m)%m  将可能的答案储存,输出最小的答案,  O(n*n log n)
C    Long Beautiful Integer standard input/output 3 s, 256 MB Submit Add to favourites x3037

  想半天,写了个假算法 一小时后就被hack了,-_-!, 当字符串 s 满足 beautiful 时 直接输出,  否则就重写一个字符串 i < k时 t[i] = s[i] , i >= k  t[i] = t[i-k], 然后比较大小 如果 t > s, 直接输出, 否则还需要再修改一下 t 让它的值更大, 当 s[i]  (i k-1~0) 小于 9 时 直接 s[i]+=1 之后的  s[i+=k]+=1 , 否则 有数位为9 则置为0, 代码如下
D    Domino for Young standard input/output 3 s, 256 MB Submit Add to favourites x1672

  用双色染色法, http://www.doc88.com/p-1438088100243.html 

 
E    K Integers standard input/output 3 s, 256 MB Submit Add to favourites x188

  过的人蛮少, 不想看

 

 

#include <bits/stdc++.h>//cfER 609div2

using namespace std;
#define ll long long
#define _for(i,a,b) for(int i = (a); i < (b); i++)
#define _rep(i,a,b) for(int i = (a); i <= (b); i++)

 

 

void taskA1(){
    ll n;
    cin >> n;
    if(n == 1) cout << "9 8";
    else if(n == 2) cout << "6 4";
    else if(n&1)cout << n*3 << " " << 2*n;
    else cout << 2*n << " " << n;
    return;
}
void taskA(){
    ll n; cin >> n;
    cout << 9*n << " " << 8*n << "\n";
    return;
}

 

void taskB(){
    int n,m; cin >> n >> m;
    vector<int> a(n,0), b(n,0), c(n,0);
    _for(i,0,n) cin >> a[i];
    _for(i,0,n) cin >> b[i];
    sort(b.begin(), b.end());
    sort(a.begin(), a.end());
    int m1 = b[0];
    set<int> s;
    _for(i,0,n) {
        int x = (m1-a[i]+m)%m;
        _for(j,0,n) c[j] = (a[j]+x)%m;
        sort(c.begin(), c.end());
        int f = 0;
        _for(j,0,n) if(c[j] != b[j]) {f = 1; break;}
        if(!f) {s.insert(x);}
    }
    //sort(ans.begin(), ans.end());
    //int y = ans[0];
    //cout << y << "\n";
    cout << *s.begin() << "\n";
    return;
}

 

void taskC(){
    int n,k; cin >> n >> k;
    string s,t; cin >> s;
    int f = 0; t = s;
    _for(i,k,n) t[i] = t[i-k];
    if(t >= s) { cout << n << "\n" << t <<"\n"; return; }

    for(int i = k-1; i >= 0; i--) 
    {
        if(t[i] != 9)    
        { 
            for(int j = i; j < n; j += k)  
                t[j]++;
            break;
        }else {
            for(int j = i; j < n; j += k)
                t[j] = 0;
        }
    }
    cout << n << "\n" << t << "\n";
    return;
}

 

void taskD(){
    int n; cin >> n;
    //vector<int> a(n);
    ll a1 = 0, b1 = 0;
    _for(i,0,n) {
        ll x;
        cin >> x;
        ll a = (x+1)/2;
        ll b = (x-a);
        if(i&1) a1 += a, b1 += b;
        else a1 += b, b1 += a;
    }
    cout << min(a1, b1) << "\n";
    return;
}

 

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    //taskA();
    //taskB();
    //taskC();
    taskD();
    return 0;
}

 

cfER 609div2

原文:https://www.cnblogs.com/163467wyj/p/12142950.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!