• Codeforces Round #674 (Div. 3)


    题目传送门

    A. Floor Number

    签到

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
     
    int n, x;
     
    inline void solve(int T)
    {
        cin >> n >> x;
        if(n <= 2) cout << "1" << endl;
        else {
            n -= 2;
            cout << ceil(1.0 * n / x) + 1 << endl;
        }
    }
     
     
    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
     
        // freopen("in.txt", "r", stdin);
        // freopen("ans.txt", "w", stdans);
     
        int T = 1;
        cin >> T;
        rep(i, 1, T) solve(i);
    }
    View Code

    B. Symmetric Matrix

    容易发现只需要一个右上角等于左下角的矩阵就可以构造任意偶数大小的矩阵

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
     
    int n, m;
    int a[4], flag, cnt;
     
    inline void solve(int T)
    {
        cin >> n >> m;
        flag = 0;
        rep(i, 1, n) {
            rep(j, 0, 3) cin >> a[j];
            if(a[1] == a[2]) flag = 1;
            
        }
        if((m & 1) || (!flag)) cout << "NO
    ";
        else cout << "YES
    ";
    }
     
     
    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
     
        // freopen("in.txt", "r", stdin);
        // freopen("ans.txt", "w", stdans);
     
        int T = 1;
        cin >> T;
        rep(i, 1, T) solve(i);
    }
    View Code

    C. Increase and Copy

    贪心的想法:先将1加x,再把$x+1$复制y份,答案要满足$(x+1)*y>=n$

    答案最多$63244$,可以直接枚举x

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
     
     
    inline void solve(int T)
    {
        int n, ans = 63244;
        cin >> n;
        rep(i, 0, 63244) if(i - 1 + ceil(1.0 * n / (i + 1)) < ans) ans = i - 1 + ceil(1.0 * n / (i + 1));
        cout << ans << endl;
    }
     
     
    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
     
        // freopen("in.txt", "r", stdin);
        // freopen("ans.txt", "w", stdans);
     
        int T = 1;
        cin >> T;
        rep(i, 1, T) solve(i);
    }
    View Code

    D. Non-zero Segments

    如果$1$至$i-1$没有和为$0$的子段,且$1$至$i$存在和为$0$的子段,那就在$i-1$和$i$之间插入一个值,值是什么不重要

    大概就是这样贪

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
     
    map<ll, ll> mp;
    ll n;
    ll tmp, sum, ans;
     
    inline void solve(int T)
    {
        mp.clear();
        sum = ans = 0;
        cin >> n;
        rep(i, 1, n) {
            cin >> tmp;
            sum += tmp;
            if(mp[sum] || sum == 0) ans++, mp.clear(), sum = tmp;
            mp[sum] = 1;
        }
        cout << ans << endl;
    }
     
     
    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
     
        // freopen("in.txt", "r", stdin);
        // freopen("ans.txt", "w", stdans);
     
        int T = 1;
        // cin >> T;
        rep(i, 1, T) solve(i);
    }
    View Code

    E. Rock, Paper, Scissors

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
    
    int n, a[3], b[3];
    
    inline void solve(int T)
    {
        cin >> n;
        rep(i, 0, 2) cin >> a[i];
        rep(i, 0, 2) cin >> b[i];
    
        cout << max(max(0, a[0] + b[1] - n), max(a[1] + b[2] - n, a[2] + b[0] - n)) << " " ;
        cout << min(a[0], b[1]) + min(a[1], b[2]) + min(a[2], b[0]) << endl;
    }
     
     
    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
     
        // freopen("in.txt", "r", stdin);
        // freopen("ans.txt", "w", stdans);
     
        int T = 1;
        // cin >> T;
        rep(i, 1, T) solve(i);
    }
    View Code
     
  • 相关阅读:
    OC学习笔记
    feed43+ifttt
    让Hyper-V和VMware虚拟机软件共存
    ios问题集
    vs2012问题集
    第二个win8应用制作笔记
    隐私策略
    《龙泉青瓷》隐私策略
    win8开发-Xaml学习笔记四
    梦想成为“老板”的第N天
  • 原文地址:https://www.cnblogs.com/likunhong/p/13764577.html
Copyright © 2020-2023  润新知