zoukankan      html  css  js  c++  java
  • Codeforces Round #675 (Div. 2)

    题目传送门

    A. Fence

    签到

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
     
    ll a, b, c;
     
     
    inline void solve(int T)
    {
        cin >> a >> b >> c;
        cout << a + b + c - 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. Nice 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++)
     
    ll n, m;
    ll ans;
    ll a[110][110];
     
    inline void solve(int T)
    {
     
        cin >> n >> m;
        rep(i, 1, n) rep(j, 1, m) cin >> a[i][j];
        ans = 0;
        rep(i, 1, n / 2) rep(j, 1, m / 2) {
            ll tmp = abs(a[i][j] - a[n - i + 1][j]) + abs(a[i][j] - a[i][m - j + 1]) + abs(a[i][j] - a[n - i + 1][m - j + 1]);
            tmp = min(tmp, abs(a[i][j] - a[n - i + 1][j]) + abs(a[n - i + 1][j] - a[i][m - j + 1]) + abs(a[n - i + 1][j] - a[n - i + 1][m - j + 1]));
            tmp = min(tmp, abs(a[i][m - j + 1] - a[n - i + 1][j]) + abs(a[i][j] - a[i][m - j + 1]) + abs(a[i][m - j + 1] - a[n - i + 1][m - j + 1]));
            tmp = min(tmp, abs(a[n - i + 1][m - j + 1] - a[n - i + 1][j]) + abs(a[n - i + 1][m - j + 1] - a[i][m - j + 1]) + abs(a[i][j] - a[n - i + 1][m - j + 1]));
            ans += tmp;
        }
        if(n & 1) rep(j, 1, m / 2) ans += abs(a[n / 2 + 1][j] - a[n / 2 + 1][m - j + 1]);
        if(m & 1) rep(i, 1, n / 2) ans += abs(a[i][m / 2 + 1] - a[n - i + 1][m / 2 + 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

    C. Bargain

    找规律,假设有长度为6的数: $a_1,a_2,a_3,a_4,a_5,a_6$

    然后找每一位的系数,

    $a_6: frac{(5 + 1) * 5}{2} * 1$

    $a_5: frac{(4 + 1) * 4}{2} * 10 + 1 * 1$

    $a_4: frac{(3 + 1) * 3}{2} * 100 + 2 * 10 + 1 * 1$

    $a_3: frac{(2 + 1) * 2}{2} * 1000 + 3 * 100 + 2 * 10 + 1 * 1$

    $a_2: frac{(2 + 1) * 2}{2} * 10000 + 4 * 1000 + 3 * 100 + 2 * 10 + 1 * 1$

    $a_1: ...$

    规律很容易看出了

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
     
    ll n;
    char s[200010];
    ll cnt, tmp, ans, mod = 1e9 + 7;
     
    inline void solve(int T)
    {
        cin >> s + 1;
        n = strlen(s + 1);
        ans = tmp = 0;
        cnt = 1;
        for(int i = n; i; i--) {
            ans = (ans + 1ll * (s[i] - '0') * i * (i - 1) / 2 % mod * cnt % mod) % mod;
            ans = (ans + 1ll * (s[i] - '0') * tmp) % mod;
            tmp = (tmp + 1ll * (n - i + 1) * cnt % mod) % mod;
            cnt = cnt * 10 % mod;
            
        }
        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
  • 相关阅读:
    python之Lambda
    oracle数据处理之expdb/impdb
    oracle之dblink
    oracle数据处理之sql*loader(二)
    exsi主机之间使用scp拷贝文件超时问题
    exsi从磁盘中加载虚拟机
    exsi的虚拟机加载U盘
    python 中的property
    hp服务器安装exsi5.5
    关于vsphere的 许可证配置问题
  • 原文地址:https://www.cnblogs.com/likunhong/p/13773622.html
Copyright © 2011-2022 走看看