0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-02 18:56:28 +00:00

fix: format all cpp codes

This commit is contained in:
Baoshuo Ren 2021-11-19 17:01:13 +08:00 committed by Baoshuo Ren
parent 9f0d4bedd0
commit f0aae01668
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68
170 changed files with 586 additions and 728 deletions

View File

@ -8,7 +8,8 @@ string s;
int main() { int main() {
cin >> s; cin >> s;
sort(s.begin(), s.end()); sort(s.begin(), s.end());
do ans++; do
ans++;
while (next_permutation(s.begin(), s.end())); while (next_permutation(s.begin(), s.end()));
cout << ans << endl; cout << ans << endl;
return 0; return 0;

View File

@ -45,8 +45,10 @@ void modify(int u, int x, int v) {
return; return;
} }
int mid = tr[u].l + tr[u].r >> 1; int mid = tr[u].l + tr[u].r >> 1;
if (x <= mid) modify(u << 1, x, v); if (x <= mid)
else modify(u << 1 | 1, x, v); modify(u << 1, x, v);
else
modify(u << 1 | 1, x, v);
pushup(u); pushup(u);
} }

View File

@ -1,3 +1,5 @@
#include <stdio.h> #include <stdio.h>
char s[] = "#include<stdio.h>%cchar%cs[]=%c%s%c%c%cint main(){printf(s,10,32,34,s,34,59,10);}"; char s[] = "#include<stdio.h>%cchar%cs[]=%c%s%c%c%cint main(){printf(s,10,32,34,s,34,59,10);}";
int main(){printf(s,10,32,34,s,34,59,10);} int main() {
printf(s, 10, 32, 34, s, 34, 59, 10);
}

View File

@ -1,6 +1,7 @@
#include "interaction.h"
#include <bits/stdc++.h> #include <bits/stdc++.h>
#include "interaction.h"
using namespace std; using namespace std;
int n; int n;

View File

@ -25,11 +25,9 @@ int main() {
} }
if (flag) { if (flag) {
cout << "No" << endl; cout << "No" << endl;
} } else {
else {
cout << "Yes" << endl; cout << "Yes" << endl;
} }
} }
return 0; return 0;
} }

View File

@ -9,8 +9,7 @@ int main() {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
if (i >= 3) { if (i >= 3) {
cin >> t; cin >> t;
} } else {
else {
t = a[i]; t = a[i];
} }
if (t % 2 != o) { if (t % 2 != o) {

View File

@ -10,11 +10,9 @@ int main() {
// abc abd acd bcd // abc abd acd bcd
if (a + b > c && a + c > b && b + c > a || a + b > d && a + d > b && b + d > a || a + c > d && a + d > c && c + d > a || b + c > d && b + d > c && c + d > b) { if (a + b > c && a + c > b && b + c > a || a + b > d && a + d > b && b + d > a || a + c > d && a + d > c && c + d > a || b + c > d && b + d > c && c + d > b) {
cout << "TRIANGLE" << endl; cout << "TRIANGLE" << endl;
} } else if (a + b >= c && a + c >= b && b + c >= a || a + b >= d && a + d >= b && b + d >= a || a + c >= d && a + d >= c && c + d >= a || b + c >= d && b + d >= c && c + d >= b) {
else if (a + b >= c && a + c >= b && b + c >= a || a + b >= d && a + d >= b && b + d >= a || a + c >= d && a + d >= c && c + d >= a || b + c >= d && b + d >= c && c + d >= b) {
cout << "SEGMENT" << endl; cout << "SEGMENT" << endl;
} } else {
else {
cout << "IMPOSSIBLE" << endl; cout << "IMPOSSIBLE" << endl;
} }
return 0; return 0;

View File

@ -18,12 +18,10 @@ int main() {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
if (p[i].first > tv1) { if (p[i].first > tv1) {
tv1 = p[i].second; tv1 = p[i].second;
} } else {
else {
if (p[i].first > tv2) { if (p[i].first > tv2) {
tv2 = p[i].second; tv2 = p[i].second;
} } else {
else {
cout << "NO" << endl; cout << "NO" << endl;
return 0; return 0;
} }

View File

@ -23,8 +23,7 @@ int main() {
for (int j = 2; j <= by; j++) { for (int j = 2; j <= by; j++) {
if (b[i][j]) { if (b[i][j]) {
continue; continue;
} } else {
else {
f[i][j] = max(f[i][j], f[i - 1][j] + f[i][j - 1]); f[i][j] = max(f[i][j], f[i - 1][j] + f[i][j - 1]);
} }
} }

View File

@ -18,14 +18,12 @@ string add(string b, int k) {
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
if (isdigit(a[i])) { if (isdigit(a[i])) {
numa[len - i] = a[i] - '0'; numa[len - i] = a[i] - '0';
} } else {
else {
numa[len - i] = a[i] - 'A' + 10; numa[len - i] = a[i] - 'A' + 10;
} }
if (isdigit(b[i])) { if (isdigit(b[i])) {
numb[len - i] = b[i] - '0'; numb[len - i] = b[i] - '0';
} } else {
else {
numb[len - i] = b[i] - 'A' + 10; numb[len - i] = b[i] - 'A' + 10;
} }
} }

View File

@ -5,25 +5,25 @@ using namespace std;
int n, l1, l2, a[100005], d1[100005], d2[100005]; int n, l1, l2, a[100005], d1[100005], d2[100005];
int main() { int main() {
while (cin >> a[++n]); while (cin >> a[++n])
;
n--; n--;
d1[++l1] = d2[++l2] = a[1]; d1[++l1] = d2[++l2] = a[1];
for (int i = 2; i <= n; i++) { for (int i = 2; i <= n; i++) {
if (d1[l1] >= a[i]) { if (d1[l1] >= a[i]) {
d1[++l1] = a[i]; d1[++l1] = a[i];
} } else {
else {
int* it = upper_bound(d1 + 1, d1 + 1 + l1, a[i], greater<int>()); int* it = upper_bound(d1 + 1, d1 + 1 + l1, a[i], greater<int>());
*it = a[i]; *it = a[i];
} }
if (d2[l2] < a[i]) { if (d2[l2] < a[i]) {
d2[++l2] = a[i]; d2[++l2] = a[i];
} } else {
else {
int* it = lower_bound(d2 + 1, d2 + 1 + l2, a[i], less<int>()); int* it = lower_bound(d2 + 1, d2 + 1 + l2, a[i], less<int>());
*it = a[i]; *it = a[i];
} }
} }
cout << l1 << endl << l2 << endl; cout << l1 << endl
<< l2 << endl;
return 0; return 0;
} }

View File

@ -14,8 +14,7 @@ int main() {
for (int j = 0; j <= n; j++) { for (int j = 0; j <= n; j++) {
if (j >= v[i]) { if (j >= v[i]) {
f[i][j] = max(f[i - 1][j], f[i - 1][j - v[i]] + w[i]); f[i][j] = max(f[i - 1][j], f[i - 1][j - v[i]] + w[i]);
} } else {
else {
f[i][j] = f[i - 1][j]; f[i][j] = f[i - 1][j];
} }
} }

View File

@ -21,8 +21,7 @@ int main() {
if (n == 5 && m == 3) { if (n == 5 && m == 3) {
printf("78 4\n2783 95\n9323 89\n7972 88\n2538 78"); printf("78 4\n2783 95\n9323 89\n7972 88\n2538 78");
return 0; return 0;
} } else if (n == 87 && m == 35) {
else if (n == 87 && m == 35) {
printf("77 52\n5081 100\n8736 100\n2855 99\n6347 99\n3191 96\n6090 95\n9917 95\n1832 94\n3169 92\n3404 92\n6982 92\n9494 92\n3535 91\n8569 91\n9319 90\n1896 89\n9701 89\n3321 88\n6017 88\n6158 88\n6361 88\n7353 88\n4011 87\n4967 87\n8017 87\n8944 87\n4746 86\n7313 86\n7486 86\n9250 86\n4808 85\n4982 85\n6979 85\n7327 85\n7887 85\n7651 84\n8456 84\n8850 84\n1423 83\n7889 82\n6891 81\n8779 81\n1174 80\n4116 80\n4141 80\n5473 80\n7172 79\n8562 79\n5392 78\n4301 77\n4551 77\n5498 77\n"); printf("77 52\n5081 100\n8736 100\n2855 99\n6347 99\n3191 96\n6090 95\n9917 95\n1832 94\n3169 92\n3404 92\n6982 92\n9494 92\n3535 91\n8569 91\n9319 90\n1896 89\n9701 89\n3321 88\n6017 88\n6158 88\n6361 88\n7353 88\n4011 87\n4967 87\n8017 87\n8944 87\n4746 86\n7313 86\n7486 86\n9250 86\n4808 85\n4982 85\n6979 85\n7327 85\n7887 85\n7651 84\n8456 84\n8850 84\n1423 83\n7889 82\n6891 81\n8779 81\n1174 80\n4116 80\n4141 80\n5473 80\n7172 79\n8562 79\n5392 78\n4301 77\n4551 77\n5498 77\n");
return 0; return 0;
} }

View File

@ -10,8 +10,7 @@ int main() {
t = (k[i % k.size()] & 31) - 1; t = (k[i % k.size()] & 31) - 1;
if ((c[i] & 31) - t > 0) { if ((c[i] & 31) - t > 0) {
c[i] = c[i] - t; c[i] = c[i] - t;
} } else {
else {
c[i] = c[i] - t + 26; c[i] = c[i] - t + 26;
} }
} }

View File

@ -15,8 +15,7 @@ int main() {
l++; l++;
r--; r--;
ans++; ans++;
} } else {
else {
r--; r--;
ans++; ans++;
} }

View File

@ -14,15 +14,13 @@ int main() {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
if (a[i] > r) { if (a[i] > r) {
p += a[i] - r; p += a[i] - r;
} } else if (a[i] < l) {
else if (a[i] < l) {
q += l - a[i]; q += l - a[i];
} }
} }
if (n * r < sum) { if (n * r < sum) {
cout << -1 << endl; cout << -1 << endl;
} } else {
else {
cout << max(p, q) << endl; cout << max(p, q) << endl;
} }
return 0; return 0;

View File

@ -14,8 +14,7 @@ int main() {
n = unique(a, a + n) - a; n = unique(a, a + n) - a;
if (k >= n) { if (k >= n) {
cout << "NO RESULT" << endl; cout << "NO RESULT" << endl;
} } else {
else {
cout << a[--k]; cout << a[--k];
} }
return 0; return 0;

View File

@ -23,8 +23,7 @@ int main() {
cin >> a[i][j]; cin >> a[i][j];
if (a[i][j] == 0) { if (a[i][j] == 0) {
b[i][j] = 0; b[i][j] = 0;
} } else {
else {
b[i][j] = 1; b[i][j] = 1;
} }
} }
@ -34,11 +33,9 @@ int main() {
for (int j = 1; j <= n; j++) { for (int j = 1; j <= n; j++) {
if (b[i][j] == 2) { if (b[i][j] == 2) {
cout << "0 "; cout << "0 ";
} } else if (b[i][j] == 0) {
else if (b[i][j] == 0) {
cout << "2 "; cout << "2 ";
} } else {
else {
cout << "1 "; cout << "1 ";
} }
} }

View File

@ -11,8 +11,7 @@ int main() {
mid = (l + r) / 2; mid = (l + r) / 2;
if (pow(1.0 / (1.0 + mid), k) >= 1 - n / m * mid) { if (pow(1.0 / (1.0 + mid), k) >= 1 - n / m * mid) {
r = mid; r = mid;
} } else {
else {
l = mid; l = mid;
} }
} }

View File

@ -12,8 +12,7 @@ int main() {
k = i / 2 + 1; k = i / 2 + 1;
if (!l.empty() && a[i] >= l.top()) { if (!l.empty() && a[i] >= l.top()) {
s.push(a[i]); s.push(a[i]);
} } else {
else {
l.push(a[i]); l.push(a[i]);
} }
while (l.size() < k) { while (l.size() < k) {

View File

@ -10,8 +10,7 @@ int main() {
if (sum + t > m) { if (sum + t > m) {
ans++; ans++;
sum = t; sum = t;
} } else {
else {
sum += t; sum += t;
} }
} }

View File

@ -9,8 +9,7 @@ bool check(int x) {
for (int i = 1; i <= n; i++) { for (int i = 1; i <= n; i++) {
if (tot + a[i] <= x) { if (tot + a[i] <= x) {
tot += a[i]; tot += a[i];
} } else {
else {
tot = a[i]; tot = a[i];
num++; num++;
} }
@ -28,8 +27,7 @@ int main() {
mid = l + r >> 1; mid = l + r >> 1;
if (check(mid)) { if (check(mid)) {
l = mid + 1; l = mid + 1;
} } else {
else {
r = mid - 1; r = mid - 1;
} }
} }

View File

@ -26,12 +26,10 @@ int main() {
if (op == 'A') { if (op == 'A') {
a[++n] = (x + t) % d; a[++n] = (x + t) % d;
change(n); change(n);
} } else if (op == 'Q') {
else if (op == 'Q') {
if (x == 1) { if (x == 1) {
cout << (t = a[n]) << endl; cout << (t = a[n]) << endl;
} } else {
else {
cout << (t = find(n - x + 1, n)) << endl; cout << (t = find(n - x + 1, n)) << endl;
} }
} }

View File

@ -8,16 +8,22 @@ int main() {
getline(cin, a); getline(cin, a);
getline(cin, b); getline(cin, b);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
if (a[i] <= 0) break; if (a[i] <= 0)
else us *= a[i] - 64; break;
else
us *= a[i] - 64;
} }
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
if (b[i] <= 0) break; if (b[i] <= 0)
else zs *= b[i] - '@'; break;
else
zs *= b[i] - '@';
} }
us %= 47; us %= 47;
zs %= 47; zs %= 47;
if (us == zs) cout << "GO" << endl; if (us == zs)
else cout << "STAY" << endl; cout << "GO" << endl;
else
cout << "STAY" << endl;
return 0; return 0;
} }

View File

@ -26,8 +26,7 @@ int main() {
for (int i = 1; i < n; i++) { for (int i = 1; i < n; i++) {
if (a[i].start <= end) { if (a[i].start <= end) {
end = max(end, a[i].end); end = max(end, a[i].end);
} } else {
else {
ans1 = max(ans1, end - start); ans1 = max(ans1, end - start);
ans2 = max(ans2, a[i].start - end); ans2 = max(ans2, a[i].start - end);
start = a[i].start; start = a[i].start;

View File

@ -22,12 +22,10 @@ int main() {
if (st.empty() || b[st.top()] != s[i]) { if (st.empty() || b[st.top()] != s[i]) {
if (s[i] == ')') { if (s[i] == ')') {
b[i] = '('; b[i] = '(';
} } else {
else {
b[i] = '['; b[i] = '[';
} }
} } else {
else {
b[st.top()] = ' '; b[st.top()] = ' ';
st.pop(); st.pop();
} }

View File

@ -17,6 +17,7 @@ int main() {
girl += (s[i] == 'g' || s[i + 1] == 'i' || s[i + 2] == 'r' || s[i + 3] == 'l'); girl += (s[i] == 'g' || s[i + 1] == 'i' || s[i + 2] == 'r' || s[i + 3] == 'l');
} }
cout << boy << endl << girl << endl; cout << boy << endl
<< girl << endl;
return 0; return 0;
} }

View File

@ -10,24 +10,21 @@ int main() {
if (ch == '.') { if (ch == '.') {
st.push(t); st.push(t);
t = 0; t = 0;
} } else if ('0' <= ch && ch <= '9') {
else if('0' <= ch && ch <= '9') {
t *= 10; t *= 10;
t += ch - '0'; t += ch - '0';
} } else {
else { b = st.top();
b = st.top(); st.pop(); st.pop();
a = st.top(); st.pop(); a = st.top();
st.pop();
if (ch == '+') { if (ch == '+') {
st.push(a + b); st.push(a + b);
} } else if (ch == '-') {
else if (ch == '-') {
st.push(a - b); st.push(a - b);
} } else if (ch == '*') {
else if (ch == '*') {
st.push(a * b); st.push(a * b);
} } else if (ch == '/') {
else if (ch == '/') {
st.push(a / b); st.push(a / b);
} }
} }

View File

@ -43,8 +43,7 @@ void modify(int u, int x, int d) {
int mid = tr[u].l + tr[u].r >> 1; int mid = tr[u].l + tr[u].r >> 1;
if (x <= mid) { if (x <= mid) {
modify(u << 1, x, d); modify(u << 1, x, d);
} } else {
else {
modify(u << 1 | 1, x, d); modify(u << 1 | 1, x, d);
} }
pushup(u); pushup(u);
@ -75,8 +74,7 @@ int main() {
cin >> op >> x >> y; cin >> op >> x >> y;
if (op == 'U') { if (op == 'U') {
modify(1, x, y); modify(1, x, y);
} } else if (op == 'Q') {
else if (op == 'Q') {
cout << query(1, x, y) << endl; cout << query(1, x, y) << endl;
} }
} }

View File

@ -22,8 +22,7 @@ int main() {
cin >> x >> y; cin >> x >> y;
if (find(x) == find(y)) { if (find(x) == find(y)) {
cout << "Yes" << endl; cout << "Yes" << endl;
} } else {
else {
cout << "No" << endl; cout << "No" << endl;
} }
} }

View File

@ -22,16 +22,13 @@ int main() {
if (a[now].towards == 0) { if (a[now].towards == 0) {
if (x == 0) { if (x == 0) {
now = (now + n - y) % n; now = (now + n - y) % n;
} } else if (x == 1) {
else if (x == 1) {
now = (now + y) % n; now = (now + y) % n;
} }
} } else if (a[now].towards == 1) {
else if (a[now].towards == 1) {
if (x == 0) { if (x == 0) {
now = (now + y) % n; now = (now + y) % n;
} } else if (x == 1) {
else if (x == 1) {
now = (now + n - y) % n; now = (now + n - y) % n;
} }
} }

View File

@ -12,8 +12,7 @@ int main() {
for (int i = 1; i < n; i++) { for (int i = 1; i < n; i++) {
if (a[i] > a[i - 1]) { if (a[i] > a[i - 1]) {
f[i] = f[i - 1] + 1; f[i] = f[i - 1] + 1;
} } else {
else {
f[i] = 0; f[i] = 0;
} }
} }

View File

@ -30,8 +30,7 @@ int main() {
if (cnt[j] == max) { if (cnt[j] == max) {
printf("%s%c", j == 0 ? "" : " ", '*'); printf("%s%c", j == 0 ? "" : " ", '*');
cnt[j]--; cnt[j]--;
} } else {
else {
printf("%s%s", j == 0 ? "" : " ", " "); printf("%s%s", j == 0 ? "" : " ", " ");
} }
} }

View File

@ -32,8 +32,7 @@ int main() {
if (d >= 365) { if (d >= 365) {
ans++; ans++;
} }
} } else {
else {
m++; m++;
} }
} }

View File

@ -15,11 +15,9 @@ int main() {
int p = lower_bound(a, a + m, q) - a; int p = lower_bound(a, a + m, q) - a;
if (p == m) { if (p == m) {
ans += q - a[m - 1]; ans += q - a[m - 1];
} } else if (p == 0) {
else if (p == 0) {
ans += a[0] - q; ans += a[0] - q;
} } else {
else {
ans += min(abs(a[p] - q), abs(q - a[p - 1])); ans += min(abs(a[p] - q), abs(q - a[p - 1]));
} }
} }

View File

@ -12,8 +12,7 @@ int main() {
while (scanf("%c", &c) != EOF) { while (scanf("%c", &c) != EOF) {
if (c == ' ') { if (c == ' ') {
cnt++; cnt++;
} } else if ('a' <= c && c <= 'z') {
else if('a' <= c && c <= 'z') {
cnt += num[c - 'a']; cnt += num[c - 'a'];
} }
// cout << c << ' ' << cnt << endl; // cout << c << ' ' << cnt << endl;

View File

@ -30,8 +30,7 @@ int main() {
cin >> l >> r; cin >> l >> r;
if (l > m || r > m || l < 1 || r < 1) { if (l > m || r > m || l < 1 || r < 1) {
cout << "Crossing the line" << endl; cout << "Crossing the line" << endl;
} } else {
else {
cout << ans[r] - ans[l - 1] << endl; cout << ans[r] - ans[l - 1] << endl;
} }
} }

View File

@ -2,7 +2,6 @@
using namespace std; using namespace std;
long long n, m, l, r, ans, a[1000005]; long long n, m, l, r, ans, a[1000005];
bool check(long long x) { bool check(long long x) {
@ -25,8 +24,7 @@ int main() {
long long mid = l + r >> 1; long long mid = l + r >> 1;
if (check(mid)) { if (check(mid)) {
l = (ans = mid) + 1; l = (ans = mid) + 1;
} } else {
else {
r = mid - 1; r = mid - 1;
} }
} }

View File

@ -29,8 +29,7 @@ int main() {
mid2 = r - (r - l) / 3.0; mid2 = r - (r - l) / 3.0;
if (check(mid1) > check(mid2)) { if (check(mid1) > check(mid2)) {
l = mid1; l = mid1;
} } else {
else {
r = mid2; r = mid2;
} }
} }

View File

@ -23,11 +23,9 @@ int main() {
} }
if (ans[3] == 1 && ans[2] == 0 && ans[1] == 0) { if (ans[3] == 1 && ans[2] == 0 && ans[1] == 0) {
cout << 100 << endl; cout << 100 << endl;
} } else if ((ans[2] + ans[3]) % 10) {
else if ((ans[2] + ans[3]) % 10) {
cout << (ans[2] + ans[3]) % 10 << (ans[1] + ans[2]) % 10 << endl; cout << (ans[2] + ans[3]) % 10 << (ans[1] + ans[2]) % 10 << endl;
} } else {
else {
cout << (ans[1] + ans[2]) % 10 << endl; cout << (ans[1] + ans[2]) % 10 << endl;
} }
return 0; return 0;

View File

@ -13,8 +13,7 @@ void merge_sort(long long a[], long long l, long long r) {
while (i <= mid && j <= r) { while (i <= mid && j <= r) {
if (a[i] <= a[j]) { if (a[i] <= a[j]) {
t[k++] = a[i++]; t[k++] = a[i++];
} } else {
else {
t[k++] = a[j++]; t[k++] = a[j++];
ans += (mid - i + 1); ans += (mid - i + 1);
} }

View File

@ -17,11 +17,9 @@ string cnm() {
while (n--) { while (n--) {
s += str; s += str;
} }
} } else if (ch == ']') {
else if (ch == ']') {
return s; return s;
} } else {
else {
s += ch; s += ch;
} }
} }

View File

@ -7,8 +7,7 @@ extern "C" int Chtholly(int n, int OvO) {
if (Seniorious(mid) >= 0) { if (Seniorious(mid) >= 0) {
ans = mid; ans = mid;
r = mid - 1; r = mid - 1;
} } else {
else {
l = mid + 1; l = mid + 1;
} }
mid = l + r >> 1; mid = l + r >> 1;

View File

@ -26,8 +26,7 @@ int main() {
for (int j = a[1]; j < a[a[0]]; j++) { for (int j = a[1]; j < a[a[0]]; j++) {
if (a[l] == j) { if (a[l] == j) {
l++; l++;
} } else {
else {
for (int k = 1; k <= a[0]; k++) { for (int k = 1; k <= a[0]; k++) {
if (!v[a[k]][j]) { if (!v[a[k]][j]) {
int t = a[k]; int t = a[k];

View File

@ -84,12 +84,10 @@ signed main() {
if (op == 1) { if (op == 1) {
cin >> k; cin >> k;
modify(1, x, y, k, 0); modify(1, x, y, k, 0);
} } else if (op == 2) {
else if (op == 2) {
cin >> k; cin >> k;
modify(1, x, y, 1, k); modify(1, x, y, 1, k);
} } else if (op == 3) {
else if (op == 3) {
cout << query(1, x, y) % p << endl; cout << query(1, x, y) % p << endl;
} }
} }

View File

@ -37,8 +37,10 @@ void modify(int u, int x, int d) {
return; return;
} }
int mid = tr[u].l + tr[u].r >> 1; int mid = tr[u].l + tr[u].r >> 1;
if (x <= mid) modify(u << 1, x, d); if (x <= mid)
else modify(u << 1 | 1, x, d); modify(u << 1, x, d);
else
modify(u << 1 | 1, x, d);
pushup(u); pushup(u);
} }
@ -60,8 +62,7 @@ int main() {
cin >> op >> a >> b; cin >> op >> a >> b;
if (op == 'x') { if (op == 'x') {
modify(1, a, b); modify(1, a, b);
} } else if (op == 'y') {
else if (op == 'y') {
cout << query(1, a, b) << endl; cout << query(1, a, b) << endl;
} }
} }

View File

@ -28,11 +28,9 @@ int main() {
long long w, c; long long w, c;
cin >> w >> c; cin >> w >> c;
a.insert(node(w, c)); a.insert(node(w, c));
} } else if (op == 2 && !a.empty()) {
else if (op == 2 && !a.empty()) {
a.erase(--a.end()); a.erase(--a.end());
} } else if (op == 3 && !a.empty()) {
else if (op == 3 && !a.empty()) {
a.erase(a.begin()); a.erase(a.begin());
} }
} }

View File

@ -15,8 +15,7 @@ int main() {
vector<int>::iterator it = lower_bound(nums.begin(), nums.end(), t); vector<int>::iterator it = lower_bound(nums.begin(), nums.end(), t);
if (*it == t) { if (*it == t) {
cout << it - nums.begin() + 1 << ' '; cout << it - nums.begin() + 1 << ' ';
} } else {
else {
cout << "-1 "; cout << "-1 ";
} }
} }

View File

@ -80,20 +80,16 @@ int main() {
if (op == 1) { if (op == 1) {
cin >> x >> y >> k; cin >> x >> y >> k;
modify(1, x, y, k); modify(1, x, y, k);
} } else if (op == 2) {
else if(op == 2) {
cin >> k; cin >> k;
modify(1, 1, 1, k); modify(1, 1, 1, k);
} } else if (op == 3) {
else if(op == 3) {
cin >> k; cin >> k;
modify(1, 1, 1, -k); modify(1, 1, 1, -k);
} } else if (op == 4) {
else if(op == 4) {
cin >> x >> y; cin >> x >> y;
cout << query(1, x, y) << endl; cout << query(1, x, y) << endl;
} } else if (op == 5) {
else if(op == 5) {
cout << query(1, 1, 1) << endl; cout << query(1, 1, 1) << endl;
} }
} }

View File

@ -7,11 +7,9 @@ int main() {
cin >> n; cin >> n;
if (n <= 8) { if (n <= 8) {
cout << 0 << endl; cout << 0 << endl;
} } else if (n == 9) {
else if(n == 9) {
cout << 8 << endl; cout << 8 << endl;
} } else {
else {
cout << 72; cout << 72;
for (int i = 10; i < n; i++) { for (int i = 10; i < n; i++) {
cout << 0; cout << 0;

View File

@ -7,51 +7,38 @@ int main() {
cin >> T; cin >> T;
if (T == 1) { if (T == 1) {
cout << "I love Luogu!"; cout << "I love Luogu!";
} } else if (T == 2) {
else if (T == 2) {
cout << 2 + 4 << " " << 10 - 2 - 4; cout << 2 + 4 << " " << 10 - 2 - 4;
} } else if (T == 3) {
else if (T == 3) {
cout << 3 << endl cout << 3 << endl
<< 12 << endl << 12 << endl
<< 2 << endl; << 2 << endl;
} } else if (T == 4) {
else if (T == 4) {
printf("%.3lf\n", 500.0 / 3.0); printf("%.3lf\n", 500.0 / 3.0);
} } else if (T == 5) {
else if (T == 5) {
cout << 15 << endl; cout << 15 << endl;
} } else if (T == 6) {
else if (T == 6) {
cout << sqrt(6 * 6 + 9 * 9) << endl; cout << sqrt(6 * 6 + 9 * 9) << endl;
} } else if (T == 7) {
else if (T == 7) {
cout << 110 << endl cout << 110 << endl
<< 90 << endl << 90 << endl
<< 0 << endl; << 0 << endl;
} } else if (T == 8) {
else if (T == 8) {
cout << 3.141593 * 5 * 2 << endl cout << 3.141593 * 5 * 2 << endl
<< 3.141593 * 5 * 5 << endl << 3.141593 * 5 * 5 << endl
<< 4.0 / 3 * 3.141593 * 5 * 5 * 5 << endl; << 4.0 / 3 * 3.141593 * 5 * 5 * 5 << endl;
} } else if (T == 9) {
else if (T == 9) {
cout << 22 << endl; cout << 22 << endl;
} } else if (T == 10) {
else if (T == 10) {
cout << 9 << endl; cout << 9 << endl;
} } else if (T == 11) {
else if (T == 11) {
cout << 100.0 / (8 - 5) << endl; cout << 100.0 / (8 - 5) << endl;
} } else if (T == 12) {
else if (T == 12) {
cout << 13 << endl cout << 13 << endl
<< "R" << endl; << "R" << endl;
} } else if (T == 13) {
else if (T == 13) {
cout << floor(pow((3.141593 * 4 * 4 * 4 * 4 / 3 + 3.141593 * 10 * 10 * 10 * 4 / 3), 1.0 / 3)) << endl; cout << floor(pow((3.141593 * 4 * 4 * 4 * 4 / 3 + 3.141593 * 10 * 10 * 10 * 4 / 3), 1.0 / 3)) << endl;
} } else if (T == 14) {
else if (T == 14) {
cout << 50 << endl; cout << 50 << endl;
} }
return 0; return 0;

View File

@ -28,4 +28,3 @@ int main() {
} }
return 0; return 0;
} }

View File

@ -81,8 +81,7 @@ int main() {
cin >> op >> x >> y; cin >> op >> x >> y;
if (op == 0) { if (op == 0) {
modify(1, x, y); modify(1, x, y);
} } else if (op == 1) {
else if (op == 1) {
cout << query(1, x, y) << endl; cout << query(1, x, y) << endl;
} }
} }

View File

@ -11,16 +11,13 @@ int main() {
if (c == 'E' && y1 < y2) { if (c == 'E' && y1 < y2) {
y1++; y1++;
ans++; ans++;
} } else if (c == 'W' && y1 > y2) {
else if(c == 'W' && y1 > y2) {
y1--; y1--;
ans++; ans++;
} } else if (c == 'N' && x1 < x2) {
else if(c == 'N' && x1 < x2) {
x1++; x1++;
ans++; ans++;
} } else if (c == 'S' && x1 > x2) {
else if(c == 'S' && x1 > x2) {
x1--; x1--;
ans++; ans++;
} }

View File

@ -9,8 +9,7 @@ int main() {
cin >> t; cin >> t;
if (t % 2 == 0) { if (t % 2 == 0) {
cout << "pb wins" << endl; cout << "pb wins" << endl;
} } else {
else {
cout << "zs wins" << endl; cout << "zs wins" << endl;
} }
} }

View File

@ -18,8 +18,7 @@ int main() {
cin >> z >> x >> y; cin >> z >> x >> y;
if (z == 1) { if (z == 1) {
f[find(x)] = find(y); f[find(x)] = find(y);
} } else {
else {
cout << (find(x) == find(y) ? "Y" : "N") << endl; cout << (find(x) == find(y) ? "Y" : "N") << endl;
} }
} }

View File

@ -81,8 +81,7 @@ int main() {
if (op == 1) { if (op == 1) {
scanf("%d%d", &y, &k); scanf("%d%d", &y, &k);
modify(1, x, y, k); modify(1, x, y, k);
} } else if (op == 2) {
else if (op == 2) {
printf("%d\n", query(1, x, x)); printf("%d\n", query(1, x, x));
} }
} }

View File

@ -10,20 +10,15 @@ int main() {
cin >> opt >> x; cin >> opt >> x;
if (opt == 1) { if (opt == 1) {
a.insert(lower_bound(a.begin(), a.end(), x), x); a.insert(lower_bound(a.begin(), a.end(), x), x);
} } else if (opt == 2) {
else if (opt == 2) {
a.erase(lower_bound(a.begin(), a.end(), x)); a.erase(lower_bound(a.begin(), a.end(), x));
} } else if (opt == 3) {
else if (opt == 3) {
cout << lower_bound(a.begin(), a.end(), x) - a.begin() + 1 << endl; cout << lower_bound(a.begin(), a.end(), x) - a.begin() + 1 << endl;
} } else if (opt == 4) {
else if (opt == 4) {
cout << a[x - 1] << endl; cout << a[x - 1] << endl;
} } else if (opt == 5) {
else if (opt == 5) {
cout << *(lower_bound(a.begin(), a.end(), x) - 1) << endl; cout << *(lower_bound(a.begin(), a.end(), x) - 1) << endl;
} } else if (opt == 6) {
else if (opt == 6) {
cout << *upper_bound(a.begin(), a.end(), x) << endl; cout << *upper_bound(a.begin(), a.end(), x) << endl;
} }
} }

View File

@ -111,8 +111,7 @@ int main() {
if (op == 1) { if (op == 1) {
cin >> k; cin >> k;
modify(1, x, y, k); modify(1, x, y, k);
} } else if (op == 2) {
else if (op == 2) {
cout << query(1, x, y) << endl; cout << query(1, x, y) << endl;
} }
} }

View File

@ -118,12 +118,10 @@ signed main() {
if (op == 1) { if (op == 1) {
cin >> k; cin >> k;
modify(1, x, y, k, 0); modify(1, x, y, k, 0);
} } else if (op == 2) {
else if (op == 2) {
cin >> k; cin >> k;
modify(1, x, y, 1, k); modify(1, x, y, 1, k);
} } else if (op == 3) {
else if (op == 3) {
cout << query(1, x, y) % p << endl; cout << query(1, x, y) % p << endl;
} }
} }

View File

@ -40,8 +40,7 @@ void change(int u, int x, int d) {
int mid = tr[u].l + tr[u].r >> 1; int mid = tr[u].l + tr[u].r >> 1;
if (x <= mid) { if (x <= mid) {
change(u << 1, x, d); change(u << 1, x, d);
} } else {
else {
change(u << 1 | 1, x, d); change(u << 1 | 1, x, d);
} }
pushup(u); pushup(u);
@ -68,8 +67,7 @@ int main() {
cin >> op >> x >> y; cin >> op >> x >> y;
if (op == 1) { if (op == 1) {
change(1, x, y); change(1, x, y);
} } else if (op == 2) {
else if (op == 2) {
cout << query(1, x, y) << endl; cout << query(1, x, y) << endl;
} }
} }

View File

@ -13,11 +13,9 @@ int main() {
int x; int x;
cin >> x; cin >> x;
q.push(x); q.push(x);
} } else if (op == 2) {
else if(op == 2) {
cout << q.top() << endl; cout << q.top() << endl;
} } else if (op == 3) {
else if(op == 3) {
q.pop(); q.pop();
} }
} }

View File

@ -24,8 +24,7 @@ int main() {
mid2 = r - (r - l) / 3.0; mid2 = r - (r - l) / 3.0;
if (f(mid1) > f(mid2)) { if (f(mid1) > f(mid2)) {
r = mid2; r = mid2;
} } else {
else {
l = mid1; l = mid1;
} }
} }

View File

@ -23,8 +23,7 @@ int main() {
for (int i = 0; i < str.size(); i++) { for (int i = 0; i < str.size(); i++) {
if (str[i] == 'V') { if (str[i] == 'V') {
str[i] = 'K'; str[i] = 'K';
} } else {
else {
str[i] = 'V'; str[i] = 'V';
} }
@ -35,8 +34,7 @@ int main() {
} }
if (str[i] == 'V') { if (str[i] == 'V') {
str[i] = 'K'; str[i] = 'K';
} } else {
else {
str[i] = 'V'; str[i] = 'V';
} }
} }

View File

@ -22,8 +22,10 @@ int main() {
} }
while (l < r) { while (l < r) {
int mid = l + r >> 1; int mid = l + r >> 1;
if (check(mid)) r = mid; if (check(mid))
else l = mid + 1; r = mid;
else
l = mid + 1;
} }
cout << l << endl; cout << l << endl;
return 0; return 0;

View File

@ -17,8 +17,7 @@ int main() {
if (op == "add") { if (op == "add") {
cin >> t; cin >> t;
nums.insert(lower_bound(nums.begin(), nums.end(), t), t); nums.insert(lower_bound(nums.begin(), nums.end(), t), t);
} } else {
else {
cout << nums[nums.size() / 2 - (nums.size() & 1 ^ 1)] << endl; cout << nums[nums.size() / 2 - (nums.size() & 1 ^ 1)] << endl;
} }
} }

View File

@ -19,8 +19,7 @@ int main() {
cin >> s; cin >> s;
if (!m.count(s)) { if (!m.count(s)) {
cout << endl; cout << endl;
} } else {
else {
for (set<int>::iterator it = m[s].begin(); it != --m[s].end(); it++) { for (set<int>::iterator it = m[s].begin(); it != --m[s].end(); it++) {
cout << *it << ' '; cout << *it << ' ';
} }

View File

@ -13,14 +13,12 @@ int main() {
ans[2] += (string) "." + s[i] + ".*"; ans[2] += (string) "." + s[i] + ".*";
ans[3] += "*.*."; ans[3] += "*.*.";
ans[4] += ".*.."; ans[4] += ".*..";
} } else {
else {
ans[0] += ".#.."; ans[0] += ".#..";
ans[1] += "#.#."; ans[1] += "#.#.";
if ((i + 1) % 3 == 2 && i + 1 != s.size()) { if ((i + 1) % 3 == 2 && i + 1 != s.size()) {
ans[2] += (string) "." + s[i] + ".*"; ans[2] += (string) "." + s[i] + ".*";
} } else {
else {
ans[2] += (string) "." + s[i] + ".#"; ans[2] += (string) "." + s[i] + ".#";
} }
ans[3] += "#.#."; ans[3] += "#.#.";

View File

@ -28,8 +28,7 @@ void euler(long long n) {
if (i % pri[j] == 0) { if (i % pri[j] == 0) {
f[i * pri[j]] = f[i] * powk[pri[j]] % mod; f[i * pri[j]] = f[i] * powk[pri[j]] % mod;
break; break;
} } else {
else {
f[i * pri[j]] = f[i] * f[pri[j]] % mod; f[i * pri[j]] = f[i] * f[pri[j]] % mod;
} }
} }

View File

@ -42,8 +42,7 @@ void modify(int u, int x, int v) {
int mid = tr[u].l + tr[u].r >> 1; int mid = tr[u].l + tr[u].r >> 1;
if (x <= mid) { if (x <= mid) {
modify(u << 1, x, v); modify(u << 1, x, v);
} } else {
else {
modify(u << 1 | 1, x, v); modify(u << 1 | 1, x, v);
} }
pushup(u); pushup(u);
@ -58,8 +57,7 @@ int main() {
cin >> op >> m; cin >> op >> m;
if (op == 1) { if (op == 1) {
modify(1, i, m); modify(1, i, m);
} } else if (op == 2) {
else if (op == 2) {
modify(1, m, 1); modify(1, m, 1);
} }
cout << tr[1].s << endl; cout << tr[1].s << endl;

View File

@ -7,11 +7,9 @@ int n, l[1000005], r[1000005];
int dfs(int now, int cnt) { int dfs(int now, int cnt) {
if (l[now] == 0 && r[now] == 0) { if (l[now] == 0 && r[now] == 0) {
return cnt; return cnt;
} } else if (l[now] == 0) {
else if (l[now] == 0) {
return dfs(r[now], cnt + 1); return dfs(r[now], cnt + 1);
} } else if (r[now] == 0) {
else if (r[now] == 0) {
return dfs(l[now], cnt + 1); return dfs(l[now], cnt + 1);
} }
return max(dfs(l[now], cnt + 1), dfs(r[now], cnt + 1)); return max(dfs(l[now], cnt + 1), dfs(r[now], cnt + 1));

View File

@ -30,8 +30,7 @@ int main() {
cin >> y; cin >> y;
add(x, 1); add(x, 1);
add(y + 1, -1); add(y + 1, -1);
} } else if (op == 1) {
else if (op == 1) {
cout << sum(x) << endl; cout << sum(x) << endl;
} }
} }

View File

@ -62,8 +62,7 @@ int main() {
if (t == 1) { if (t == 1) {
cin >> y; cin >> y;
change(1, x, y); change(1, x, y);
} } else {
else {
cout << query(1, x) << endl; cout << query(1, x) << endl;
} }
} }

View File

@ -11,20 +11,16 @@ int main() {
if (x == 1) { if (x == 1) {
if (m.count(y)) { if (m.count(y)) {
cout << "Already Exist" << endl; cout << "Already Exist" << endl;
} } else {
else {
m[y] = 1; m[y] = 1;
} }
} } else {
else {
if (m.empty()) { if (m.empty()) {
cout << "Empty" << endl; cout << "Empty" << endl;
} } else if (m.count(y)) {
else if (m.count(y)) {
m.erase(y); m.erase(y);
cout << y << endl; cout << y << endl;
} } else {
else {
m[y] = 1; m[y] = 1;
map<int, int>::iterator it = m.find(y); map<int, int>::iterator it = m.find(y);
map<int, int>::iterator it2 = it; map<int, int>::iterator it2 = it;
@ -32,16 +28,13 @@ int main() {
if (it2 == m.begin()) { if (it2 == m.begin()) {
cout << it->first << endl; cout << it->first << endl;
m.erase(it); m.erase(it);
} } else if (it == m.end()) {
else if (it == m.end()) {
cout << (--it2)->first << endl; cout << (--it2)->first << endl;
m.erase(it2); m.erase(it2);
} } else if (y - (--it2)->first > it->first - y) {
else if (y - (--it2)->first > it->first - y) {
cout << it->first << endl; cout << it->first << endl;
m.erase(it); m.erase(it);
} } else {
else {
cout << it2->first << endl; cout << it2->first << endl;
m.erase(it2); m.erase(it2);
} }

View File

@ -13,27 +13,22 @@ int main() {
cin >> s >> b; cin >> s >> b;
students[s] = b; students[s] = b;
cout << "OK" << endl; cout << "OK" << endl;
} } else if (q == 2) {
else if (q == 2) {
cin >> s; cin >> s;
if (students.find(s) != students.end()) { if (students.find(s) != students.end()) {
cout << students[s] << endl; cout << students[s] << endl;
} } else {
else {
cout << "Not found" << endl; cout << "Not found" << endl;
} }
} } else if (q == 3) {
else if (q == 3) {
cin >> s; cin >> s;
if (students.find(s) != students.end()) { if (students.find(s) != students.end()) {
students.erase(s); students.erase(s);
cout << "Deleted successfully" << endl; cout << "Deleted successfully" << endl;
} } else {
else {
cout << "Not found" << endl; cout << "Not found" << endl;
} }
} } else if (q == 4) {
else if(q == 4) {
cout << students.size() << endl; cout << students.size() << endl;
} }
} }

View File

@ -11,8 +11,7 @@ int main() {
for (long long i = 0; i < tmp.size(); i++) { for (long long i = 0; i < tmp.size(); i++) {
if (tmp[i] == '<') { if (tmp[i] == '<') {
if (!s[n].empty()) s[n].pop_back(); if (!s[n].empty()) s[n].pop_back();
} } else {
else {
s[n].push_back(tmp[i]); s[n].push_back(tmp[i]);
} }
} }
@ -22,8 +21,7 @@ int main() {
for (long long i = 0; i < tmp.size(); i++) { for (long long i = 0; i < tmp.size(); i++) {
if (tmp[i] == '<') { if (tmp[i] == '<') {
if (!r[m].empty()) r[m].pop_back(); if (!r[m].empty()) r[m].pop_back();
} } else {
else {
r[m].push_back(tmp[i]); r[m].push_back(tmp[i]);
} }
} }

View File

@ -9,8 +9,7 @@ int main() {
if ((1ull << n) - 1 < k) { if ((1ull << n) - 1 < k) {
printf("1"); printf("1");
k = (1ull << n) - k + (1ull << n) - 1; k = (1ull << n) - k + (1ull << n) - 1;
} } else {
else {
printf("0"); printf("0");
} }
} }

View File

@ -13,8 +13,7 @@ int main() {
} }
if (s.size() <= 1) { if (s.size() <= 1) {
cout << -1 << endl; cout << -1 << endl;
} } else {
else {
t = 0; t = 0;
for (int i : s) { for (int i : s) {
a[++t] = i; a[++t] = i;

View File

@ -8,39 +8,31 @@ int main() {
if (1 <= m && m <= 12) { if (1 <= m && m <= 12) {
if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) { if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
t = 31; t = 31;
} } else if (m == 2) {
else if (m == 2) {
t = 28; t = 28;
} } else {
else {
t = 30; t = 30;
} }
if (1 <= d && d <= t) { if (1 <= d && d <= t) {
ans = 0; ans = 0;
} } else {
else {
ans = 1; ans = 1;
} }
} } else if (12 < m && m < 20) {
else if (12 < m && m < 20) {
if (1 <= d && d <= 31) { if (1 <= d && d <= 31) {
ans = 1; ans = 1;
} } else {
else {
ans = 2; ans = 2;
} }
} } else {
else {
if (m % 10 == 1 || m % 10 == 2 || m % 10 == 3 || m % 10 == 5 || m % 10 == 7 || m % 10 == 8) { if (m % 10 == 1 || m % 10 == 2 || m % 10 == 3 || m % 10 == 5 || m % 10 == 7 || m % 10 == 8) {
t = 31; t = 31;
} } else {
else {
t = 30; t = 30;
} }
if (1 <= d && d <= t) { if (1 <= d && d <= t) {
ans = 1; ans = 1;
} } else {
else {
ans = 2; ans = 2;
} }
} }

View File

@ -14,8 +14,7 @@ int main() {
m %= 60; m %= 60;
if (h > 7) { if (h > 7) {
printf("%02d", 24 + 7 - h); printf("%02d", 24 + 7 - h);
} } else {
else {
printf("%02d", 7 - h); printf("%02d", 7 - h);
} }
printf(":%02d\n", 60 - m); printf(":%02d\n", 60 - m);

View File

@ -6,7 +6,6 @@ using namespace std;
int n, k, a[15][15], ax, ay; int n, k, a[15][15], ax, ay;
int main() { int main() {
k = ax = 1; k = ax = 1;

View File

@ -17,27 +17,23 @@ int main() {
cin >> s1; cin >> s1;
s += s1; s += s1;
cout << s; cout << s;
} } else if (act == 2) {
else if (act == 2) {
int st, ed; int st, ed;
cin >> st >> ed; cin >> st >> ed;
s = s.substr(st, ed); s = s.substr(st, ed);
cout << s; cout << s;
} } else if (act == 3) {
else if (act == 3) {
int st; int st;
string s1; string s1;
cin >> st >> s1; cin >> st >> s1;
s.insert(st, s1); s.insert(st, s1);
cout << s; cout << s;
} } else if (act == 4) {
else if (act == 4) {
string s1; string s1;
cin >> s1; cin >> s1;
if (s.find(s1) < s.size()) { if (s.find(s1) < s.size()) {
cout << s.find(s1); cout << s.find(s1);
} } else {
else {
cout << "-1"; cout << "-1";
} }
} }

View File

@ -52,8 +52,7 @@ int main() {
if (query(a[i], a[j])) { if (query(a[i], a[j])) {
if (a[i].name < a[j].name) { if (a[i].name < a[j].name) {
cout << a[i].name << ' ' << a[j].name << endl; cout << a[i].name << ' ' << a[j].name << endl;
} } else {
else {
cout << a[j].name << ' ' << a[i].name << endl; cout << a[j].name << ' ' << a[i].name << endl;
} }
} }

View File

@ -11,8 +11,7 @@ int main() {
cin >> tmp >> x >> s; cin >> tmp >> x >> s;
if (x + s > 140 && x * 0.7 + s * 0.3 >= 80) { if (x + s > 140 && x * 0.7 + s * 0.3 >= 80) {
cout << "Excellent" << endl; cout << "Excellent" << endl;
} } else {
else {
cout << "Not excellent" << endl; cout << "Not excellent" << endl;
} }
} }

View File

@ -9,8 +9,7 @@ int main() {
int n = 30; int n = 30;
if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) { if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) {
n = 31; n = 31;
} } else if (i == 2) {
else if (i == 2) {
n = 28; n = 28;
} }
for (int j = 1; j <= n; j++) { for (int j = 1; j <= n; j++) {

View File

@ -8,12 +8,16 @@ int main() {
string a, b, a_max, b_max, a_min, b_min; string a, b, a_max, b_max, a_min, b_min;
cin >> a >> b; cin >> a >> b;
for (int i = 0; i < a.size(); i++) { for (int i = 0; i < a.size(); i++) {
if(a[i] == '6' || a[i] == '5') a_max += '6', a_min += '5'; if (a[i] == '6' || a[i] == '5')
else a_max += a[i], a_min += a[i]; a_max += '6', a_min += '5';
else
a_max += a[i], a_min += a[i];
} }
for (int i = 0; i < b.size(); i++) { for (int i = 0; i < b.size(); i++) {
if(b[i] == '6' || b[i] == '5') b_max += '6', b_min += '5'; if (b[i] == '6' || b[i] == '5')
else b_max += b[i], b_min += b[i]; b_max += '6', b_min += '5';
else
b_max += b[i], b_min += b[i];
} }
cout << atoi(a_min.c_str()) + atoi(b_min.c_str()) << ' ' << atoi(a_max.c_str()) + atoi(b_max.c_str()) << endl; cout << atoi(a_min.c_str()) + atoi(b_min.c_str()) << ' ' << atoi(a_max.c_str()) + atoi(b_max.c_str()) << endl;
return 0; return 0;

View File

@ -9,8 +9,7 @@ int main() {
cin >> a >> b >> c >> d >> e >> f >> g >> h >> i; cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
if ((h && 50 + a + b + c + d + e + f + g + 5 >= i) || (50 + a + b + c + d + e + f + g >= i)) { if ((h && 50 + a + b + c + d + e + f + g + 5 >= i) || (50 + a + b + c + d + e + f + g >= i)) {
cout << "AKIOI" << endl; cout << "AKIOI" << endl;
} } else {
else {
cout << "AFO" << endl; cout << "AFO" << endl;
} }
return 0; return 0;

View File

@ -7,8 +7,7 @@ int main() {
cin >> n; cin >> n;
if (n & 1) { if (n & 1) {
cout << -1 << endl; cout << -1 << endl;
} } else {
else {
for (int i = 24; i > 0; i--) { for (int i = 24; i > 0; i--) {
if (n >> i & 1) { if (n >> i & 1) {
cout << (1 << i) << ' '; cout << (1 << i) << ' ';

View File

@ -14,8 +14,7 @@ long long dfs(int x, int y, int from) {
} }
if (from == 0) { if (from == 0) {
f[x][y][from] = max({dfs(x + 1, y, 0), dfs(x, y - 1, 0), dfs(x, y - 1, 1)}) + w[x][y]; f[x][y][from] = max({dfs(x + 1, y, 0), dfs(x, y - 1, 0), dfs(x, y - 1, 1)}) + w[x][y];
} } else {
else {
f[x][y][from] = max({dfs(x - 1, y, 1), dfs(x, y - 1, 0), dfs(x, y - 1, 1)}) + w[x][y]; f[x][y][from] = max({dfs(x - 1, y, 1), dfs(x, y - 1, 0), dfs(x, y - 1, 1)}) + w[x][y];
} }
return f[x][y][from]; return f[x][y][from];

View File

@ -29,8 +29,7 @@ void dfs(int x, __int128 first, __int128 second) {
__int128 tmp = gcd(ans[x].first, ans[x].second); __int128 tmp = gcd(ans[x].first, ans[x].second);
ans[x].first /= tmp; ans[x].first /= tmp;
ans[x].second /= tmp; ans[x].second /= tmp;
} } else {
else {
first *= ans[x].second; first *= ans[x].second;
ans[x].first *= second; ans[x].first *= second;
ans[x].first += first; ans[x].first += first;
@ -39,8 +38,7 @@ void dfs(int x, __int128 first, __int128 second) {
ans[x].first /= tmp; ans[x].first /= tmp;
ans[x].second /= tmp; ans[x].second /= tmp;
} }
} } else {
else {
ans[x].first = first; ans[x].first = first;
ans[x].second = second; ans[x].second = second;
} }

View File

@ -8,18 +8,14 @@ int main() {
cin >> score; cin >> score;
if (score >= 90) { if (score >= 90) {
gpa = 4.0; gpa = 4.0;
} } else if (60 <= score && score <= 89) {
else if (60 <= score && score <= 89) {
gpa = 4.0 - (90 - score) * 0.1; gpa = 4.0 - (90 - score) * 0.1;
} } else {
else {
if (floor(sqrt(score) * 10.0) >= 90.0) { if (floor(sqrt(score) * 10.0) >= 90.0) {
gpa = 4.0; gpa = 4.0;
} } else if (floor(sqrt(score) * 10.0) >= 60.0) {
else if (floor(sqrt(score) * 10.0) >= 60.0) {
gpa = 4.0 - (90.0 - floor(sqrt(score) * 10.0)) * 0.1; gpa = 4.0 - (90.0 - floor(sqrt(score) * 10.0)) * 0.1;
} } else {
else {
gpa = 0.0; gpa = 0.0;
} }
} }

View File

@ -13,19 +13,16 @@ int main() {
for (int i = 0; i < s.size(); i++) { for (int i = 0; i < s.size(); i++) {
if (s[i] == '(' || s[i] == '[') { if (s[i] == '(' || s[i] == '[') {
st.push(s[i]); st.push(s[i]);
} } else if (st.empty() || s[i] == ')' && st.top() != '(' || s[i] == ']' && st.top() != '[') {
else if (st.empty() || s[i] == ')' && st.top() != '(' || s[i] == ']' && st.top() != '[') {
cout << "No" << endl; cout << "No" << endl;
goto end; goto end;
} } else {
else {
st.pop(); st.pop();
} }
} }
if (st.empty()) { if (st.empty()) {
cout << "Yes" << endl; cout << "Yes" << endl;
} } else {
else {
cout << "No" << endl; cout << "No" << endl;
} }
end:; end:;

View File

@ -11,11 +11,9 @@ bool check(long long x) {
for (i = 1; i < n; i++) { for (i = 1; i < n; i++) {
if (a[i] == -1) { if (a[i] == -1) {
t[++top] = x; t[++top] = x;
} } else if (a[i] > 0) {
else if (a[i] > 0) {
t[++top] = a[i]; t[++top] = a[i];
} } else if (top > 1) {
else if (top > 1) {
t[top - 1] += t[top]; t[top - 1] += t[top];
top--; top--;
} }
@ -40,8 +38,7 @@ int main() {
mid = l + r + 1 >> 1; mid = l + r + 1 >> 1;
if (check(mid)) { if (check(mid)) {
l = mid; l = mid;
} } else {
else {
r = mid - 1; r = mid - 1;
} }
} }