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
待填坑