A 1234567891011121314151617181920#include <bits/stdc++.h>using namespace std;int t, n;int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> t; while (t--) { cin >> n; if (n & 1) { cout << 0 << "\n"; } else { cout << (n / 4) + 1 << "\n"; } } return 0;} B 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#include <bits/stdc++.h>using namespace std;const int MAXN = 2e5 + 5;int t, n;long long a[MAXN];int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> t; while (t--) { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; long long ans = 0; if (a[1] != -1 && a[n] != -1) { ans = llabs(a[n] - a[1]); } else { ans = 0; if (a[1] == -1 && a[n] == -1) { a[1] = 0; a[n] = 0; } else if (a[1] == -1) { a[1] = a[n]; } else { a[n] = a[1]; } } for (int i = 1; i <= n; i++) { if (a[i] == -1) a[i] = 0; } cout << ans << "\n"; for (int i = 1; i <= n; i++) { if (i > 1) cout << ' '; cout << a[i]; } cout << "\n"; } return 0;} Dashboard - Codeforces Round 1071 (Div. 3) - Codeforces A 1234567891011121314151617#include <bits/stdc++.h>using namespace std;long long k, x;int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { cin >> k >> x; cout << k * x + 1 << endl; } return 0;} B 12345678910111213141516171819202122232425262728293031323334353637383940#include <bits/stdc++.h>using namespace std;const int MAXN = 200000 + 5;int t, n;int a[MAXN];int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> t; while (t--) { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; long long S = 0; for (int i = 1; i <= n - 1; i++) { S += llabs((long long)a[i] - a[i + 1]); } long long best = 0; best = max(best, llabs((long long)a[1] - a[2])); best = max(best, llabs((long long)a[n - 1] - a[n])); for (int k = 2; k <= n - 1; k++) { long long left = llabs((long long)a[k - 1] - a[k]); long long right = llabs((long long)a[k] - a[k + 1]); long long merged = llabs((long long)a[k - 1] - a[k + 1]); long long delta = left + right - merged; best = max(best, delta); } cout << (S - best) << "\n"; } return 0;} C 题解 123456789101112131415161718192021222324252627282930313233343536373839#include <bits/stdc++.h>using namespace std;const int MAXN = 200000 + 5;int t, n;long long a[MAXN];int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> t; while (t--) { cin >> n; long long mn = (1LL << 62); for (int i = 1; i <= n; i++) { cin >> a[i]; mn = min(mn, a[i]); } long long mindiff = (1LL << 62); bool ok = true; for (int i = 1; i <= n; i++) { if (a[i] == mn) continue; long long d = a[i] - mn; mindiff = min(mindiff, d); if (d <= mn) ok = false; } long long ans = mn; if (ok) ans = mindiff; cout << ans << "\n"; } return 0;}