zoukankan      html  css  js  c++  java
  • 【ATcoder】AtCoder Beginner Contest 163

    A - Circle Pond

    计算圆的面积

    #include <iostream>
    #include <cstdio>
    #include <cmath>
    using namespace std;
    const double Pi = acos(-1);
    double r;
    int main() {
        cin >> r;
        printf("%.20lf", 2 * Pi * r);
        return 0;
    }

    B - Homework

    全部加起来,如果n小于和则输出-1,否则输出n-和。

    #include <iostream>
    #include <cstdio>
    using namespace std;
    int n, m;
    int a[10010], sum;
    int main() {
        scanf("%d%d", &n, &m);
        for (int i = 1; i <= m; i++) scanf("%d", &a[i]), sum += a[i];
        if (n < sum) {
            puts("-1");
        } else {
            cout << n - sum;
        }
        return 0;
    }

    C - management

    输出出度即可

    #include <iostream>
    #include <cstdio>
    using namespace std;
    const int N = 400010;
    int n;
    int out[N];
    int main() {
        cin >> n;
        for (int i = 2; i <= n; i++) {
            int a;
            cin >> a;
            out[a]++;
        }
        for (int i = 1; i <= n; i++) {
            cout << out[i] << "
    ";
        }
        return 0;
    }

    D - Sum of Large Numbers

    题解待填坑

    #include <iostream>
    #include <cstdio>
    using namespace std;
    typedef long long ll;
    const ll mod = 1e9 + 7;
    const ll N = 200010;
    ll n, k, ans;
    ll presum[N], sufsum[N];
    int main() {
        cin >> n >> k;
        for (ll i = 0; i <= n; i++) {
            presum[i] = presum[i - 1] + i;
        }
        for (ll i = n; i >= 0; i--) {
            sufsum[i] = sufsum[i + 1] + i;
        }
        for (ll i = k; i <= n + 1; i++) {
            ans = (ans + (sufsum[n - i + 1] - presum[i - 1] + 1)) % mod;
        }
        cout << ans;
        return 0;
    }

    E - Active Infants

    待填坑

    F - path pass i

    待填坑

  • 相关阅读:
    浏览器HTTP缓存原理分析
    基本概念复习
    什么是IOC为什么要使用IOC
    AutoFac记录
    NHibernate之旅(21):探索对象状态
    如何获取类或属性的自定义特性(Attribute)
    a different object with the same identifier value was already associated with the session
    6 CLR实例构造器
    6 CLR静态构造器
    CLR via C# 提纲
  • 原文地址:https://www.cnblogs.com/zcr-blog/p/12790730.html
Copyright © 2011-2022 走看看