# A

## 代码

#include <bits/stdc++.h>
#define ll long long

using namespace std;

struct node {
ll l, r;
}a[200007];

int main() {
std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n;
cin >> n;
for (int i = 0;i < n;i++) {
int x, r;
cin >> x >> r;
a[i].l = x - r;
a[i].r = x + r;
}
sort(a, a + n, [&](node a, node b) {return a.l < b.l;});
ll ans = 0, prer = a[0].r;
for (int i = 1;i < n;i++) {
if (a[i].l > prer)ans += a[i].l - prer;
prer = max(prer, a[i].r);
}
cout << ans << '\n';
return 0;
}


# C

## 代码

#include <bits/stdc++.h>
#define ll long long

using namespace std;

int X[200007], Y[200007], Xrow[200007], Xgd0[200007], Xgdm[200007];

int main() {
std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, m, k, q;
cin >> n >> m >> k >> q;
for (int i = 1;i <= k;i++) cin >> X[i] >> Y[i];
while (q--) {
int id;
cin >> id;
cin >> X[id] >> Y[id];
for (int y = 1;y <= m;y++) Xrow[y] = n + 1;
for (int i = 1;i <= k;i++) Xrow[Y[i]] = min(Xrow[Y[i]], X[i]);///更新某行最靠前的人
double k = 0;
for (int y = 1;y <= m;y++) {
k = max(k, 1.0 * (y - 1) / Xrow[y]);///更新(0,1)射线最大斜率
if (k == 0) Xgd0[y] = Xrow[y] - 1;///斜率为0
else Xgd0[y] = 1.0 * (y - 1) / k - 1e-9;///(x,x+1] = x，最大斜率与第y行交点（可能超过n）
}
k = 0;
for (int y = m;y >= 1;y--) {
k = min(k, 1.0 * (y - m) / Xrow[y]);///更新(0,m)射线最小斜率
if (k == 0) Xgdm[y] = Xrow[y] - 1;
else Xgdm[y] = 1.0 * (y - m) / k - 1e-9;
}
ll ans = 0;
for (int y = 1;y <= m;y++) ans += min({ n,Xgd0[y],Xgdm[y] });
cout << ans << '\n';
}
return 0;
}


# D

## 代码

#include <bits/stdc++.h>
#define ll long long

using namespace std;

bool solve() {
double r, x, y, d;
cin >> r >> x >> y >> d;
double len = sqrt(x * x + y * y);
double radA = acos((len - d) / r);
double radB = acos((len + d) / r);
cout << fixed << setprecision(7) << r * (radA - radB) << '\n';
return true;
}

int main() {
std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while (t--) {
if (!solve()) cout << -1 << '\n';
}
return 0;
}


# G

## 代码

#include <bits/stdc++.h>

using namespace std;

int main() {
std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
string s1;
cin >> s1;
string s2(s1.length() - 1, '9');
cout << (s1 > s2 ? s1 : s2) << '\n';
return 0;
}


# I

## 题解

$dp[i][j] = \frac{3j}{i}(dp[i-1][j-2]+1) + \frac{i-3j}{i}(dp[i-1][j] + 1)$

## 代码

#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int mod = 1e9 + 7;
int dp[14], inv[124];

void inverse(int n) {
inv[1] = 1;
for (int i = 2;i <= n;i++)
inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
}

bool solve() {
string s;
cin >> s;
set<int> st;
int cnt = 13;
for (int i = 0;i < s.size();i += 2) {
if (!st.count((s[i] - '0') * 100 + (s[i + 1] - 'a')))
st.insert((s[i] - '0') * 100 + (s[i + 1] - 'a'));
else
cnt -= 2;
}
cout << dp[cnt] << '\n';
return true;
}

int main() {
std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
inverse(123);
for (int i = 1;i <= 123;i++) {///还剩下多少张，不能摸了多少张，因为摸了第0张是要求的，而还剩0张单牌1~13的局数是0
for (int j = 13;j >= 1;j--) {
if (i >= 3 * j)
dp[j] = ((1LL * 3 * j * dp[max(0, j - 2)] +
1LL * (i - 3 * j) * dp[j]) % mod * inv[i] + 1) % mod;///概率x期望 = 新期望，j=1时，没dp[j-2]，但期望是0，因此要特判
}
}
int t = 1;
cin >> t;
for (int i = 1;i <= t;i++) {
cout << "Case #" << i << ": ";
if (!solve()) cout << -1 << '\n';
}
return 0;
}

原文作者：空白菌
原文地址: https://www.cnblogs.com/BlankYang/p/16522704.html
本文转自网络文章，转载此文章仅为分享知识，如有侵权，请联系博主进行删除。