zoukankan      html  css  js  c++  java
  • Codeforces Round #587 (Div. 3)

    Codeforces Round #587 (Div. 3)

    A. Prefixes

    • 思路:水题

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    int n, cnt;
    string s;
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> n >> s;
        for (int i = 0; i < n; i += 2){
            if (s[i] == s[i + 1]){
                cnt ++ ;
                if (s[i] == 'b')
                    s[i] = 'a';
                else
                    s[i] = 'b';
            }
        }
        cout << cnt << "
    " << s << "
    ";
        return 0;
    }
    

    B. Shooting

    • 思路:贪心 写个struct 从大到小排序计算

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    const int N = 1010;
    
    struct node{
        int a, id;
    }a[N];
    
    inline bool cmp(const node &a, const node &b){
        return a.a > b.a;
    }
    
    int n, ans;
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> n;
        for (int i = 1; i <= n; i ++ ){
            cin >> a[i].a;
            a[i].id = i;
        }
        sort(a + 1, a + n + 1, cmp);
        for (int i = 1; i <= n; i ++ )
            ans += a[i].a * (i - 1) + 1;
        cout << ans << "
    ";
        for (int i = 1; i < n; i ++ )
            cout << a[i].id << " ";
        cout << a[n].id << "
    ";
        return 0;
    }
    

    C. White Sheet

    • 思路:把所有不可能的情况枚举出来

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    int x1, y1_, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> x1 >> y1_ >> x2 >> y2 >> x3 >> y3 >> x4 >> y4 >> x5 >> y5 >> x6 >> y6;
        if ((x1 >= x3 && x2 <= x4 && y1_ >= y3 && y2 <= y4) || (x1 >= x5 && x2 <= x6 && y1_ >= y5 && y2 <= y6))
            cout << "NO
    ";
        else if ((y1_ >= y3 && y2 <= y4 && y1_ >= y5 && y2 <= y6) && (x1 >= x3 && x2 <= x6 && x4 >= x5 || x1 >= x5 && x2 <= x4 && x3 <= x6))
            cout << "NO
    ";
        else if ((x1 >= x3 && x2 <= x4 && x1 >= x5 && x2 <= x6) && (y1_ >= y3 && y2 <= y6 && y4 >= y5 || y1_ >= y5 && y2 <= y4 && y3 <= y6))
            cout << "NO
    ";
        else
            cout << "YES
    ";
        return 0;
    }
    

    D. Swords

    • 思路:排序后求最大的和其他每一项的差之和与gcd 答案为(sum / gcd)(gcd)

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    const int N = 2e5 + 10;
    
    int n;
    ll sum, gcd_;
    ll a[N];
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> n;
        for (int i = 1; i <= n; i ++ )
            cin >> a[i];
        sort(a + 1, a + n + 1);
        for (int i = 1; i < n; i ++ ){
            sum += a[n] - a[i];
            gcd_ = gcd(gcd_, a[n] - a[i]);
        }
        cout << sum / gcd_ << " " << gcd_ << "
    ";
        return 0;
    }
    

    E1. Numerical Sequence (easy version)

    • 思路:只会easy version 暴力搞

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    int q, tot;
    ll k;
    string s;
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> q;
        while (q -- ){
            tot = 1;
            s.clear();
            cin >> k;
            while (s.length() < k){
                k -= s.length();
                s += to_string(tot ++ );
            }
            cout << s[k - 1] << "
    ";
        }
        return 0;
    }
    
  • 相关阅读:
    14.4.6 Configuring Thread Concurrency for InnoDB 配置Thread 并发
    14.4.5 Configuring InnoDB Change Buffering 配置InnoDB Change Buffering
    14.4.4 Configuring the Memory Allocator for InnoDB InnoDB 配置内存分配器
    timeout connect 10000 # default 10 second time out if a backend is not found
    haproxy 服务端超时时间 timeout server 17000 --后台程序17秒没有响应,返回超时
    Openstack组件部署 — Nova_安装和配置Controller Node
    Openstack组件部署 — Nova_安装和配置Controller Node
    输出和模型使用 2
    输出和模型使用 1
    Openstack组件部署 — Nova overview
  • 原文地址:https://www.cnblogs.com/Misuchii/p/11801528.html
Copyright © 2011-2022 走看看