首页 > 其他 > 详细

【ATcoder】AtCoder Beginner Contest 163

时间:2020-04-27 23:15:42      阅读:75      评论:0      收藏:0      [点我收藏+]

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] << "\n";
    }
    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

待填坑

【ATcoder】AtCoder Beginner Contest 163

原文:https://www.cnblogs.com/zcr-blog/p/12790730.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!