• AtCoder Beginner Contest 206(Sponsored by Panasonic)


    AtCoder Beginner Contest 206(Sponsored by Panasonic)

    A - Maxi-Buying

    int main() {
        IOS; int x; cin >> x; x = floor(x * 1.08);
        if (x < 206) cout << "Yay!";
        else if (x == 206) cout << "so-so";
        else cout << ":(";
        return 0;
    }
    

    B - Savings

    int main() {
        IOS; ll x; cin >> x;
        ll s = floor(sqrt(x <<= 1));
        cout << (s * (s + 1) >= x ? s : s + 1);
        return 0;
    }
    

    C - Swappable

    int main() {
        IOS; map<int, int> st; cin >> n;
        rep (i, 1, n) {
            cin >> m; ++st[m];
            ans += i - st[m];
        }
        cout << ans;
        return 0;
    }
    

    D - KAIBUNsyo

    int f[N], a[N];
    
    int ff(int x) { return f[x] == x ? x : f[x] = ff(f[x]); }
    
    void unit(int x, int y) { if ((x = ff(x)) ^ (y = ff(y))) f[y] = x; }
    
    int main() {
        IOS; cin >> n;
        rep (i, 1, n) cin >> a[i], f[a[i]] = a[i];
        rep (i, 1, n >> 1) {
            a[i] = ff(a[i]), a[n + 1 - i] = ff(a[n + 1- i]);
            if (a[i] ^ a[n + 1 - i]) unit(a[i], a[n + 1 - i]), ++m;
        }
        cout << m;
        return 0;
    }
    

    E - Divide Both

    容斥

    ll c[N], a[N], ans;
    
    int main() {
        IOS; cin >> n >> m;
        rep (i, 2, m >> 1)
            for (int j = (n - 1) / i * i + i; j <= m; j += i) ++c[i];
        per (i, m >> 1, 2) {
            a[i] = c[i] * (c[i] - 1);
            for (int j = i * 2; j <= m; j += i) a[i] -= a[j];
            ans += a[i];
            if (i >= n) ans -= c[i] - 1 << 1;
        }
        cout << ans;
        return 0;
    }
    
  • 相关阅读:
    Linux makefile 教程 非常详细,且易懂
    PCRE函数简介和使用示例
    Eclipse常用快捷键汇总
    vc6.0 调用ocx控件
    理解串口流控
    c++ xml markup
    unresolved external symbol __endthreadex错误解决(
    Android自动化~1
    数据库左连接,右连接,内连接,外连接
    Linux常用指令
  • 原文地址:https://www.cnblogs.com/2aptx4869/p/14927478.html
Copyright © 2020-2023  润新知