From f0aae0166819f1d6ab3f4af32ce7386b0c5a7ffb Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Fri, 19 Nov 2021 17:01:13 +0800 Subject: [PATCH] fix: format all cpp codes --- AcWing/616/616.cpp | 2 +- AcWing/843/843.cpp | 4 +-- AtCoder/ABC225/A/A.cpp | 3 +- LibreOJ/10127/10127.cpp | 8 ++++-- LibreOJ/4/4.cpp | 8 ++++-- LibreOJ/6/6.cpp | 3 +- Luogu/CF1146A/CF1146A.cpp | 2 +- Luogu/CF12A/CF12A.cpp | 6 ++-- Luogu/CF1421A/CF1421A.cpp | 4 +-- Luogu/CF1445A/CF1445A.cpp | 6 ++-- Luogu/CF14A/CF14A.cpp | 6 ++-- Luogu/CF25A/CF25A.cpp | 5 ++-- Luogu/CF25B/CF25B.cpp | 2 +- Luogu/CF2A/CF2A.cpp | 6 ++-- Luogu/CF6A/CF6A.cpp | 6 ++-- Luogu/CF845C/CF845C.cpp | 18 ++++++------ Luogu/CF9A/CF9A.cpp | 2 +- Luogu/P1002/P1002.cpp | 9 +++--- Luogu/P1015/P1015.cpp | 18 ++++++------ Luogu/P1020/P1020.cpp | 12 ++++---- Luogu/P1024/P1024.cpp | 2 +- Luogu/P1060/P1060.cpp | 3 +- Luogu/P1068/P1068.cpp | 3 +- Luogu/P1079/P1079.cpp | 7 ++--- Luogu/P1093/P1093.cpp | 16 +++++------ Luogu/P1094/P1094.cpp | 3 +- Luogu/P1097/P1097.cpp | 4 +-- Luogu/P1101/P1101.cpp | 10 +++---- Luogu/P1102/P1102.cpp | 4 +-- Luogu/P1104/P1104.cpp | 4 +-- Luogu/P1109/P1109.cpp | 6 ++-- Luogu/P1130/P1130.cpp | 16 +++++------ Luogu/P1138/P1138.cpp | 3 +- Luogu/P1143/P1143.cpp | 2 +- Luogu/P1152/P1152.cpp | 12 ++++---- Luogu/P1157/P1157.cpp | 4 +-- Luogu/P1161/P1161.cpp | 8 +++--- Luogu/P1162/P1162.cpp | 9 ++---- Luogu/P1163/P1163.cpp | 3 +- Luogu/P1168/P1168.cpp | 17 ++++++------ Luogu/P1170/P1170.cpp | 10 +++---- Luogu/P1181/P1181.cpp | 3 +- Luogu/P1182/P1182.cpp | 6 ++-- Luogu/P1198/P1198.cpp | 6 ++-- Luogu/P1200/P1200.cpp | 18 ++++++++---- Luogu/P1204/P1204.cpp | 3 +- Luogu/P1205/P1205.cpp | 2 +- Luogu/P1216/P1216.cpp | 14 +++++----- Luogu/P1241/P1241.cpp | 6 ++-- Luogu/P1265/P1265.cpp | 6 ++-- Luogu/P1271/P1271.cpp | 8 +++--- Luogu/P1304/P1304.cpp | 2 +- Luogu/P1320/P1320.cpp | 22 +++++++-------- Luogu/P1321/P1321.cpp | 5 ++-- Luogu/P1352/P1352.cpp | 4 +-- Luogu/P1359/P1359.cpp | 2 +- Luogu/P1438/P1438.cpp | 10 +++---- Luogu/P1449/P1449.cpp | 25 ++++++++--------- Luogu/P1531/P1531.cpp | 6 ++-- Luogu/P1540/P1540.cpp | 6 ++-- Luogu/P1551/P1551.cpp | 3 +- Luogu/P1554/P1554.cpp | 12 ++++---- Luogu/P1563/P1563.cpp | 13 ++++----- Luogu/P1567/P1567.cpp | 3 +- Luogu/P1597/P1597.cpp | 26 +++++++++--------- Luogu/P1598/P1598.cpp | 5 ++-- Luogu/P1603/P1603.cpp | 58 +++++++++++++++++++-------------------- Luogu/P1605/P1605.cpp | 2 +- Luogu/P1614/P1614.cpp | 10 +++---- Luogu/P1634/P1634.cpp | 8 +++--- Luogu/P1664/P1664.cpp | 3 +- Luogu/P1678/P1678.cpp | 6 ++-- Luogu/P1679/P1679.cpp | 2 +- Luogu/P1706/P1706.cpp | 4 +-- Luogu/P1724/P1724.cpp | 2 +- Luogu/P1738/P1738.cpp | 4 +-- Luogu/P1755/P1755.cpp | 12 ++++---- Luogu/P1765/P1765.cpp | 5 ++-- Luogu/P1789/P1789.cpp | 6 ++-- Luogu/P1827/P1827.cpp | 8 +++--- Luogu/P1865/P1865.cpp | 3 +- Luogu/P1873/P1873.cpp | 4 +-- Luogu/P1883/P1883.cpp | 3 +- Luogu/P1897/P1897.cpp | 2 +- Luogu/P1898/P1898.cpp | 8 ++---- Luogu/P1908/P1908.cpp | 3 +- Luogu/P1928/P1928.cpp | 12 ++++---- Luogu/P1947/P1947.cpp | 3 +- Luogu/P1983/P1983.cpp | 7 ++--- Luogu/P2023/P2023.cpp | 6 ++-- Luogu/P2068/P2068.cpp | 9 +++--- Luogu/P2073/P2073.cpp | 8 ++---- Luogu/P2084/P2084.cpp | 2 +- Luogu/P2097/P2097.cpp | 2 +- Luogu/P2249/P2249.cpp | 5 ++-- Luogu/P2357/P2357.cpp | 12 +++----- Luogu/P2368/P2368.cpp | 12 ++++---- Luogu/P2369/P2369.cpp | 2 +- Luogu/P2404/P2404.cpp | 4 +-- Luogu/P2433/P2433.cpp | 41 ++++++++++----------------- Luogu/P2550/P2550.cpp | 13 ++++----- Luogu/P2574/P2574.cpp | 3 +- Luogu/P2640/P2640.cpp | 2 +- Luogu/P2676/P2676.cpp | 12 ++++---- Luogu/P2678/P2678.cpp | 2 +- Luogu/P2689/P2689.cpp | 17 +++++------- Luogu/P2846/P2846.cpp | 6 ++-- Luogu/P2911/P2911.cpp | 14 +++++----- Luogu/P3150/P3150.cpp | 3 +- Luogu/P3156/P3156.cpp | 2 +- Luogu/P3367/P3367.cpp | 11 ++++---- Luogu/P3368/P3368.cpp | 3 +- Luogu/P3369/P3369.cpp | 17 ++++-------- Luogu/P3372/P3372.cpp | 3 +- Luogu/P3373/P3373.cpp | 6 ++-- Luogu/P3374/P3374.cpp | 6 ++-- Luogu/P3378/P3378.cpp | 12 ++++---- Luogu/P3382/P3382.cpp | 3 +- Luogu/P3391/P3391.cpp | 2 +- Luogu/P3613/P3613.cpp | 14 +++++----- Luogu/P3717/P3717.cpp | 6 ++-- Luogu/P3741/P3741.cpp | 8 ++---- Luogu/P3853/P3853.cpp | 6 ++-- Luogu/P3871/P3871.cpp | 13 ++++----- Luogu/P3879/P3879.cpp | 3 +- Luogu/P3912/P3912.cpp | 10 +++---- Luogu/P3916/P3916.cpp | 2 +- Luogu/P4325/P4325.cpp | 6 ++-- Luogu/P4327/P4327.cpp | 6 ++-- Luogu/P4445/P4445.cpp | 10 +++---- Luogu/P4449/P4449.cpp | 3 +- Luogu/P4588/P4588.cpp | 6 ++-- Luogu/P4715/P4715.cpp | 2 +- Luogu/P4913/P4913.cpp | 6 ++-- Luogu/P4939/P4939.cpp | 3 +- Luogu/P5057/P5057.cpp | 3 +- Luogu/P5143/P5143.cpp | 8 +++--- Luogu/P5250/P5250.cpp | 27 +++++++----------- Luogu/P5266/P5266.cpp | 19 +++++-------- Luogu/P5318/P5318.cpp | 8 +++--- Luogu/P5587/P5587.cpp | 6 ++-- Luogu/P5657/P5657.cpp | 3 +- Luogu/P5682/P5682.cpp | 3 +- Luogu/P5690/P5690.cpp | 24 ++++++---------- Luogu/P5707/P5707.cpp | 5 ++-- Luogu/P5731/P5731.cpp | 19 ++++++------- Luogu/P5734/P5734.cpp | 18 +++++------- Luogu/P5738/P5738.cpp | 4 +-- Luogu/P5739/P5739.cpp | 2 +- Luogu/P5740/P5740.cpp | 12 ++++---- Luogu/P5741/P5741.cpp | 31 ++++++++++----------- Luogu/P5742/P5742.cpp | 3 +- Luogu/P5743/P5743.cpp | 2 +- Luogu/P5744/P5744.cpp | 6 ++-- Luogu/P5908/P5908.cpp | 4 +-- Luogu/P6382/P6382.cpp | 6 ++-- Luogu/P6408/P6408.cpp | 10 +++---- Luogu/P6449/P6449.cpp | 3 +- Luogu/P6500/P6500.cpp | 18 +++++++----- Luogu/P6832/P6832.cpp | 2 +- Luogu/P6850/P6850.cpp | 3 +- Luogu/P7071/P7071.cpp | 3 +- Luogu/P7072/P7072.cpp | 2 +- Luogu/P7074/P7074.cpp | 5 ++-- Luogu/P7079/P7079.cpp | 4 +-- Luogu/P7113/P7113.cpp | 6 ++-- Luogu/T160508/T160508.cpp | 12 +++----- Luogu/UVA673/UVA673.cpp | 9 ++---- S2OJ/183/183.cpp | 9 ++---- S2OJ/438/438.cpp | 4 +-- 170 files changed, 586 insertions(+), 728 deletions(-) diff --git a/AcWing/616/616.cpp b/AcWing/616/616.cpp index 562a0870..95ca4dc0 100644 --- a/AcWing/616/616.cpp +++ b/AcWing/616/616.cpp @@ -5,6 +5,6 @@ using namespace std; int main() { double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; - cout << fixed << setprecision(4) << sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)) << endl; + cout << fixed << setprecision(4) << sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)) << endl; return 0; } diff --git a/AcWing/843/843.cpp b/AcWing/843/843.cpp index 22cf4740..3f383751 100644 --- a/AcWing/843/843.cpp +++ b/AcWing/843/843.cpp @@ -27,8 +27,8 @@ void dfs(int u) { int main() { cin >> n; - for(int i = 0 ; i < n ; i++) { - for(int j = 0 ; j < n ; j++) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { g[i][j] = '.'; } } diff --git a/AtCoder/ABC225/A/A.cpp b/AtCoder/ABC225/A/A.cpp index de28d6d9..2335bd36 100644 --- a/AtCoder/ABC225/A/A.cpp +++ b/AtCoder/ABC225/A/A.cpp @@ -8,7 +8,8 @@ string s; int main() { cin >> s; sort(s.begin(), s.end()); - do ans++; + do + ans++; while (next_permutation(s.begin(), s.end())); cout << ans << endl; return 0; diff --git a/LibreOJ/10127/10127.cpp b/LibreOJ/10127/10127.cpp index 1c4bdd9c..a3b402cd 100644 --- a/LibreOJ/10127/10127.cpp +++ b/LibreOJ/10127/10127.cpp @@ -45,8 +45,10 @@ void modify(int u, int x, int v) { return; } int mid = tr[u].l + tr[u].r >> 1; - if (x <= mid) modify(u << 1, x, v); - else modify(u << 1 | 1, x, v); + if (x <= mid) + modify(u << 1, x, v); + else + modify(u << 1 | 1, x, v); pushup(u); } @@ -64,4 +66,4 @@ int main() { } } return 0; -} \ No newline at end of file +} diff --git a/LibreOJ/4/4.cpp b/LibreOJ/4/4.cpp index 37bbb8f7..03c9c724 100644 --- a/LibreOJ/4/4.cpp +++ b/LibreOJ/4/4.cpp @@ -1,3 +1,5 @@ -#include -char s[]="#include%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);} \ No newline at end of file +#include +char s[] = "#include%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); +} \ No newline at end of file diff --git a/LibreOJ/6/6.cpp b/LibreOJ/6/6.cpp index 2d3b70c1..becad131 100644 --- a/LibreOJ/6/6.cpp +++ b/LibreOJ/6/6.cpp @@ -1,6 +1,7 @@ -#include "interaction.h" #include +#include "interaction.h" + using namespace std; int n; diff --git a/Luogu/CF1146A/CF1146A.cpp b/Luogu/CF1146A/CF1146A.cpp index 68ead811..3780c8cb 100644 --- a/Luogu/CF1146A/CF1146A.cpp +++ b/Luogu/CF1146A/CF1146A.cpp @@ -4,7 +4,7 @@ using namespace std; int main() { char c; - int n = 0, a = 0; + int n = 0, a = 0; while (cin >> c) { n++; if (c == 'a') { diff --git a/Luogu/CF12A/CF12A.cpp b/Luogu/CF12A/CF12A.cpp index 8ca5fa72..37b9db93 100644 --- a/Luogu/CF12A/CF12A.cpp +++ b/Luogu/CF12A/CF12A.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace std; @@ -10,8 +10,8 @@ int main() { s += t; cin >> t; s += t; - for(int i = 0 ; i < 9 ; i++) { - if(s[i] != s[8-i]) { + for (int i = 0; i < 9; i++) { + if (s[i] != s[8 - i]) { cout << "NO" << endl; return 0; } diff --git a/Luogu/CF1421A/CF1421A.cpp b/Luogu/CF1421A/CF1421A.cpp index 61b5a2e7..aafa346f 100644 --- a/Luogu/CF1421A/CF1421A.cpp +++ b/Luogu/CF1421A/CF1421A.cpp @@ -1,11 +1,11 @@ -#include +#include using namespace std; int main() { int t, a, b; cin >> t; - while(t--) { + while (t--) { cin >> a >> b; cout << a + b - (a & b) * 2 << endl; } diff --git a/Luogu/CF1445A/CF1445A.cpp b/Luogu/CF1445A/CF1445A.cpp index 92f75fcd..8f5d3991 100644 --- a/Luogu/CF1445A/CF1445A.cpp +++ b/Luogu/CF1445A/CF1445A.cpp @@ -6,7 +6,7 @@ int main() { int t; cin >> t; while (t--) { - int n, x, a[55], b[55]; + int n, x, a[55], b[55]; bool flag = false; cin >> n >> x; for (int i = 0; i < n; i++) { @@ -25,11 +25,9 @@ int main() { } if (flag) { cout << "No" << endl; - } - else { + } else { cout << "Yes" << endl; } } return 0; } - diff --git a/Luogu/CF14A/CF14A.cpp b/Luogu/CF14A/CF14A.cpp index 61147f60..9a52a182 100644 --- a/Luogu/CF14A/CF14A.cpp +++ b/Luogu/CF14A/CF14A.cpp @@ -3,9 +3,9 @@ using namespace std; int main() { - int n, m; - int minx = 0x3f3f3f, miny = 0x3f3f3f; - int maxx = 0x000000, maxy = 0x000000; + int n, m; + int minx = 0x3f3f3f, miny = 0x3f3f3f; + int maxx = 0x000000, maxy = 0x000000; string s[55]; cin >> n >> m; for (int i = 0; i < n; i++) { diff --git a/Luogu/CF25A/CF25A.cpp b/Luogu/CF25A/CF25A.cpp index d7d31041..4e4c15f2 100644 --- a/Luogu/CF25A/CF25A.cpp +++ b/Luogu/CF25A/CF25A.cpp @@ -9,12 +9,11 @@ int main() { for (int i = 0; i < n; i++) { if (i >= 3) { cin >> t; - } - else { + } else { t = a[i]; } if (t % 2 != o) { - cout << i+1 << endl; + cout << i + 1 << endl; return 0; } } diff --git a/Luogu/CF25B/CF25B.cpp b/Luogu/CF25B/CF25B.cpp index 7eab1645..7fc77c84 100644 --- a/Luogu/CF25B/CF25B.cpp +++ b/Luogu/CF25B/CF25B.cpp @@ -3,7 +3,7 @@ using namespace std; int main() { - int n; + int n; string s; cin >> n >> s; for (int i = 0; i < n; i++) { diff --git a/Luogu/CF2A/CF2A.cpp b/Luogu/CF2A/CF2A.cpp index f91ddfcd..0e3d38e7 100644 --- a/Luogu/CF2A/CF2A.cpp +++ b/Luogu/CF2A/CF2A.cpp @@ -3,9 +3,9 @@ using namespace std; int main() { - int n, t, max_score = -0x3f3f3f3f; - int scores[1005]; - string s, max_player, players[1005]; + int n, t, max_score = -0x3f3f3f3f; + int scores[1005]; + string s, max_player, players[1005]; map m, m1; cin >> n; for (int i = 0; i < n; i++) { diff --git a/Luogu/CF6A/CF6A.cpp b/Luogu/CF6A/CF6A.cpp index 1b6bd827..a8a52168 100644 --- a/Luogu/CF6A/CF6A.cpp +++ b/Luogu/CF6A/CF6A.cpp @@ -10,11 +10,9 @@ int main() { // 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) { 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; - } - else { + } else { cout << "IMPOSSIBLE" << endl; } return 0; diff --git a/Luogu/CF845C/CF845C.cpp b/Luogu/CF845C/CF845C.cpp index d802e0af..5ed943e2 100644 --- a/Luogu/CF845C/CF845C.cpp +++ b/Luogu/CF845C/CF845C.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace std; @@ -10,20 +10,18 @@ int main() { int n; pair p[200005]; cin >> n; - for(int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { cin >> p[i].first >> p[i].second; } - sort(p, p+n, cmp); + sort(p, p + n, cmp); int tv1 = -1, tv2 = -1; - for(int i = 0 ; i < n ; i++) { - if(p[i].first > tv1) { + for (int i = 0; i < n; i++) { + if (p[i].first > tv1) { tv1 = p[i].second; - } - else { - if(p[i].first > tv2) { + } else { + if (p[i].first > tv2) { tv2 = p[i].second; - } - else { + } else { cout << "NO" << endl; return 0; } diff --git a/Luogu/CF9A/CF9A.cpp b/Luogu/CF9A/CF9A.cpp index 6b0b91fa..c5f1d3b9 100644 --- a/Luogu/CF9A/CF9A.cpp +++ b/Luogu/CF9A/CF9A.cpp @@ -5,7 +5,7 @@ using namespace std; int main() { - int a, b, c; + int a, b, c; string ans; cin >> a >> b; c = max(a, b); diff --git a/Luogu/P1002/P1002.cpp b/Luogu/P1002/P1002.cpp index 8ce94839..6023176a 100644 --- a/Luogu/P1002/P1002.cpp +++ b/Luogu/P1002/P1002.cpp @@ -4,9 +4,9 @@ using namespace std; const int fx[] = {0, -2, -1, 1, 2, 2, 1, -1, -2}; const int fy[] = {0, 1, 2, 2, 1, -1, -2, -2, -1}; -int bx, by, mx, my; +int bx, by, mx, my; long long f[30][30]; -bool b[30][30]; +bool b[30][30]; int main() { cin >> bx >> by >> mx >> my; @@ -14,7 +14,7 @@ int main() { by += 2; mx += 2; my += 2; - f[2][2] = 1; + f[2][2] = 1; b[mx][my] = true; for (int i = 1; i <= 8; i++) { b[mx + fx[i]][my + fy[i]] = true; @@ -23,8 +23,7 @@ int main() { for (int j = 2; j <= by; j++) { if (b[i][j]) { continue; - } - else { + } else { f[i][j] = max(f[i][j], f[i - 1][j] + f[i][j - 1]); } } diff --git a/Luogu/P1015/P1015.cpp b/Luogu/P1015/P1015.cpp index f17e3497..ac65fe06 100644 --- a/Luogu/P1015/P1015.cpp +++ b/Luogu/P1015/P1015.cpp @@ -9,30 +9,28 @@ bool check(string s) { } string add(string b, int k) { - string a = b; - char sixt[20] = "0123456789ABCDEF"; + string a = b; + char sixt[20] = "0123456789ABCDEF"; reverse(a.begin(), a.end()); - int numa[105], numb[105], numc[105]; - int len = a.length(), lenc = 1; + int numa[105], numb[105], numc[105]; + int len = a.length(), lenc = 1; string ans; for (int i = 0; i < len; i++) { if (isdigit(a[i])) { numa[len - i] = a[i] - '0'; - } - else { + } else { numa[len - i] = a[i] - 'A' + 10; } if (isdigit(b[i])) { numb[len - i] = b[i] - '0'; - } - else { + } else { numb[len - i] = b[i] - 'A' + 10; } } int x = 0; while (lenc <= len) { numc[lenc] = numa[lenc] + numb[lenc] + x; - x = numc[lenc] / k; + x = numc[lenc] / k; numc[lenc] %= k; lenc++; } @@ -47,7 +45,7 @@ string add(string b, int k) { } int main() { - int n; + int n; string m; cin >> n >> m; for (int i = 0; i <= 30; i++) { diff --git a/Luogu/P1020/P1020.cpp b/Luogu/P1020/P1020.cpp index 9e104f54..9a0c90e4 100644 --- a/Luogu/P1020/P1020.cpp +++ b/Luogu/P1020/P1020.cpp @@ -5,25 +5,25 @@ using namespace std; int n, l1, l2, a[100005], d1[100005], d2[100005]; int main() { - while (cin >> a[++n]); + while (cin >> a[++n]) + ; n--; d1[++l1] = d2[++l2] = a[1]; for (int i = 2; i <= n; i++) { if (d1[l1] >= a[i]) { d1[++l1] = a[i]; - } - else { + } else { int* it = upper_bound(d1 + 1, d1 + 1 + l1, a[i], greater()); *it = a[i]; } if (d2[l2] < a[i]) { d2[++l2] = a[i]; - } - else { + } else { int* it = lower_bound(d2 + 1, d2 + 1 + l2, a[i], less()); *it = a[i]; } } - cout << l1 << endl << l2 << endl; + cout << l1 << endl + << l2 << endl; return 0; } diff --git a/Luogu/P1024/P1024.cpp b/Luogu/P1024/P1024.cpp index 992b433c..294c99af 100644 --- a/Luogu/P1024/P1024.cpp +++ b/Luogu/P1024/P1024.cpp @@ -5,7 +5,7 @@ using namespace std; double a, b, c, d; -int cnt; +int cnt; double fc(double x) { return a * x * x * x + b * x * x + c * x + d; diff --git a/Luogu/P1060/P1060.cpp b/Luogu/P1060/P1060.cpp index 536e25b4..aa617345 100644 --- a/Luogu/P1060/P1060.cpp +++ b/Luogu/P1060/P1060.cpp @@ -14,8 +14,7 @@ int main() { for (int j = 0; j <= n; j++) { if (j >= v[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]; } } diff --git a/Luogu/P1068/P1068.cpp b/Luogu/P1068/P1068.cpp index 83b9c8fa..1a5914cb 100644 --- a/Luogu/P1068/P1068.cpp +++ b/Luogu/P1068/P1068.cpp @@ -21,8 +21,7 @@ int main() { if (n == 5 && m == 3) { printf("78 4\n2783 95\n9323 89\n7972 88\n2538 78"); 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"); return 0; } diff --git a/Luogu/P1079/P1079.cpp b/Luogu/P1079/P1079.cpp index 20f3ad19..3f8d0631 100644 --- a/Luogu/P1079/P1079.cpp +++ b/Luogu/P1079/P1079.cpp @@ -4,14 +4,13 @@ using namespace std; int main() { string k, c; - int t = 0; + int t = 0; cin >> k >> c; for (int i = 0; i < c.size(); i++) { t = (k[i % k.size()] & 31) - 1; - if((c[i] & 31) - t > 0) { + if ((c[i] & 31) - t > 0) { c[i] = c[i] - t; - } - else { + } else { c[i] = c[i] - t + 26; } } diff --git a/Luogu/P1093/P1093.cpp b/Luogu/P1093/P1093.cpp index edfbcae8..aa0fcf2d 100644 --- a/Luogu/P1093/P1093.cpp +++ b/Luogu/P1093/P1093.cpp @@ -1,10 +1,10 @@ -#include +#include using namespace std; struct node { int chinese, math, english, all, id; - + node() { id = chinese = math = english = all = 0; } @@ -18,8 +18,8 @@ struct node { }; bool cmp(node a, node b) { - if(a.all == b.all) { - if(a.chinese == b.chinese) { + if (a.all == b.all) { + if (a.chinese == b.chinese) { return a.id < b.id; } return a.chinese > b.chinese; @@ -31,13 +31,13 @@ int main() { int n; node a[305]; cin >> n; - for(int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { cin >> a[i].chinese >> a[i].math >> a[i].english; a[i].all = a[i].chinese + a[i].math + a[i].english; - a[i].id = i+1; + a[i].id = i + 1; } - sort(a, a+n, cmp); - for(int i = 0 ; i < 5 ; i++) { + sort(a, a + n, cmp); + for (int i = 0; i < 5; i++) { cout << a[i].id << ' ' << a[i].all << endl; } return 0; diff --git a/Luogu/P1094/P1094.cpp b/Luogu/P1094/P1094.cpp index c82b03eb..4f6ebb04 100644 --- a/Luogu/P1094/P1094.cpp +++ b/Luogu/P1094/P1094.cpp @@ -15,8 +15,7 @@ int main() { l++; r--; ans++; - } - else { + } else { r--; ans++; } diff --git a/Luogu/P1097/P1097.cpp b/Luogu/P1097/P1097.cpp index aebefaeb..372d536b 100644 --- a/Luogu/P1097/P1097.cpp +++ b/Luogu/P1097/P1097.cpp @@ -3,9 +3,9 @@ using namespace std; int main() { - set s; + set s; map m; - int n, t; + int n, t; cin >> n; while (n--) { cin >> t; diff --git a/Luogu/P1101/P1101.cpp b/Luogu/P1101/P1101.cpp index 57f3b1cb..3fa5bf39 100644 --- a/Luogu/P1101/P1101.cpp +++ b/Luogu/P1101/P1101.cpp @@ -2,11 +2,11 @@ using namespace std; -int n; -int u[8] = {0, -1, -1, -1, 0, 1, 1, 1}; -int v[8] = {1, 1, 0, -1, -1, -1, 0, 1}; -bool vis[101][101]; -string s[105]; +int n; +int u[8] = {0, -1, -1, -1, 0, 1, 1, 1}; +int v[8] = {1, 1, 0, -1, -1, -1, 0, 1}; +bool vis[101][101]; +string s[105]; map wd; bool dfs(int x, int y, char w, int p) { diff --git a/Luogu/P1102/P1102.cpp b/Luogu/P1102/P1102.cpp index b7d973fc..fa65a703 100644 --- a/Luogu/P1102/P1102.cpp +++ b/Luogu/P1102/P1102.cpp @@ -3,8 +3,8 @@ using namespace std; int main() { - long long n, c, ans = 0; - int a[200005]; + long long n, c, ans = 0; + int a[200005]; map b; cin >> n >> c; for (int i = 1; i <= n; i++) { diff --git a/Luogu/P1104/P1104.cpp b/Luogu/P1104/P1104.cpp index 8523cd08..2777a406 100644 --- a/Luogu/P1104/P1104.cpp +++ b/Luogu/P1104/P1104.cpp @@ -6,7 +6,7 @@ using namespace std; struct node { string name; - int y, m, d, i; + int y, m, d, i; node() { name = ""; @@ -28,7 +28,7 @@ bool cmp(node a, node b) { } int main() { - int n; + int n; node a[1005]; cin >> n; for (int i = 0; i < n; i++) { diff --git a/Luogu/P1109/P1109.cpp b/Luogu/P1109/P1109.cpp index 8b564f2f..8efd95b3 100644 --- a/Luogu/P1109/P1109.cpp +++ b/Luogu/P1109/P1109.cpp @@ -14,15 +14,13 @@ int main() { for (int i = 0; i < n; i++) { if (a[i] > r) { p += a[i] - r; - } - else if (a[i] < l) { + } else if (a[i] < l) { q += l - a[i]; } } if (n * r < sum) { cout << -1 << endl; - } - else { + } else { cout << max(p, q) << endl; } return 0; diff --git a/Luogu/P1130/P1130.cpp b/Luogu/P1130/P1130.cpp index 7ac7774e..282f5fc5 100644 --- a/Luogu/P1130/P1130.cpp +++ b/Luogu/P1130/P1130.cpp @@ -1,23 +1,23 @@ -#include +#include using namespace std; int main() { long long n, m, a[2005][2005], f[2005][2005]; cin >> n >> m; - for(int i = 1 ; i <= m ; i++) { - for(int j = 1 ; j <= n ; j++) { + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= n; j++) { cin >> a[j][i]; } } - for(int i = 1 ; i <= n ; i++) { - f[i-1][0] = f[i-1][m]; - for(int j = 1 ; j <= m ; j++) { - f[i][j] = a[i][j] + min(f[i-1][j], f[i-1][j-1]); + for (int i = 1; i <= n; i++) { + f[i - 1][0] = f[i - 1][m]; + for (int j = 1; j <= m; j++) { + f[i][j] = a[i][j] + min(f[i - 1][j], f[i - 1][j - 1]); } } long long ans = f[n][1]; - for(int i = 2 ; i <= m ; i++) { + for (int i = 2; i <= m; i++) { ans = min(ans, f[n][i]); } cout << ans << endl; diff --git a/Luogu/P1138/P1138.cpp b/Luogu/P1138/P1138.cpp index 3ebf6525..a798ace2 100644 --- a/Luogu/P1138/P1138.cpp +++ b/Luogu/P1138/P1138.cpp @@ -14,8 +14,7 @@ int main() { n = unique(a, a + n) - a; if (k >= n) { cout << "NO RESULT" << endl; - } - else { + } else { cout << a[--k]; } return 0; diff --git a/Luogu/P1143/P1143.cpp b/Luogu/P1143/P1143.cpp index 56f7ec66..7f18be22 100644 --- a/Luogu/P1143/P1143.cpp +++ b/Luogu/P1143/P1143.cpp @@ -62,7 +62,7 @@ char itoc(int x) { int main() { long long i, n = 0, p1, p2, x = 1; - string s, res = ""; + string s, res = ""; cin >> p1 >> s >> p2; for (i = s.size() - 1; i >= 0; i--) { n += ctoi(s[i]) * x; diff --git a/Luogu/P1152/P1152.cpp b/Luogu/P1152/P1152.cpp index 2df452f9..c55607ec 100644 --- a/Luogu/P1152/P1152.cpp +++ b/Luogu/P1152/P1152.cpp @@ -1,6 +1,6 @@ // R38820772 -#include +#include using namespace std; @@ -9,12 +9,12 @@ int n, a[1005]; int main() { cin >> n; - for(int i = 0 ; i < n ; i++) { - cin >>a[i]; + for (int i = 0; i < n; i++) { + cin >> a[i]; } - for(int i = 1 ; i < n ; i++) { - if(!cnt[abs(a[i]-a[i-1])]) { - cnt[abs(a[i]-a[i-1])] = true; + for (int i = 1; i < n; i++) { + if (!cnt[abs(a[i] - a[i - 1])]) { + cnt[abs(a[i] - a[i - 1])] = true; } else { cout << "Not jolly" << endl; return 0; diff --git a/Luogu/P1157/P1157.cpp b/Luogu/P1157/P1157.cpp index e7070986..16aa92fc 100644 --- a/Luogu/P1157/P1157.cpp +++ b/Luogu/P1157/P1157.cpp @@ -4,8 +4,8 @@ using namespace std; -int n, m; -int num[105]; +int n, m; +int num[105]; bool vis[105]; void dfs(int k) { diff --git a/Luogu/P1161/P1161.cpp b/Luogu/P1161/P1161.cpp index 323331df..0959f641 100644 --- a/Luogu/P1161/P1161.cpp +++ b/Luogu/P1161/P1161.cpp @@ -1,6 +1,6 @@ // R36448353 -#include +#include using namespace std; @@ -10,10 +10,10 @@ int main() { double a; n = t = ans = 0; cin >> n; - for(int i = 1 ; i <= n ; i++) { + for (int i = 1; i <= n; i++) { cin >> a >> t; - for(int j = 1 ; j <= t ; j++) { - ans ^= int(j*a); + for (int j = 1; j <= t; j++) { + ans ^= int(j * a); } } cout << ans << endl; diff --git a/Luogu/P1162/P1162.cpp b/Luogu/P1162/P1162.cpp index c9c4ee80..6ce13447 100644 --- a/Luogu/P1162/P1162.cpp +++ b/Luogu/P1162/P1162.cpp @@ -23,8 +23,7 @@ int main() { cin >> a[i][j]; if (a[i][j] == 0) { b[i][j] = 0; - } - else { + } else { b[i][j] = 1; } } @@ -34,11 +33,9 @@ int main() { for (int j = 1; j <= n; j++) { if (b[i][j] == 2) { cout << "0 "; - } - else if (b[i][j] == 0) { + } else if (b[i][j] == 0) { cout << "2 "; - } - else { + } else { cout << "1 "; } } diff --git a/Luogu/P1163/P1163.cpp b/Luogu/P1163/P1163.cpp index 444ffd12..566d4f42 100644 --- a/Luogu/P1163/P1163.cpp +++ b/Luogu/P1163/P1163.cpp @@ -11,8 +11,7 @@ int main() { mid = (l + r) / 2; if (pow(1.0 / (1.0 + mid), k) >= 1 - n / m * mid) { r = mid; - } - else { + } else { l = mid; } } diff --git a/Luogu/P1168/P1168.cpp b/Luogu/P1168/P1168.cpp index cf0cda27..eb7712ce 100644 --- a/Luogu/P1168/P1168.cpp +++ b/Luogu/P1168/P1168.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace std; @@ -7,24 +7,23 @@ int main() { priority_queue, less > s; priority_queue, greater > l; cin >> n; - for(int i = 1 ; i <= n ; i++) { + for (int i = 1; i <= n; i++) { cin >> a[i]; - k = i/2+1; - if(!l.empty() && a[i] >= l.top()) { + k = i / 2 + 1; + if (!l.empty() && a[i] >= l.top()) { s.push(a[i]); - } - else { + } else { l.push(a[i]); } - while(l.size() < k) { + while (l.size() < k) { l.push(s.top()); s.pop(); } - while(s.size() < k) { + while (s.size() < k) { s.push(l.top()); l.pop(); } - if(i%2) { + if (i % 2) { cout << s.top() << endl; } } diff --git a/Luogu/P1170/P1170.cpp b/Luogu/P1170/P1170.cpp index b63b5b78..a7dd6f53 100644 --- a/Luogu/P1170/P1170.cpp +++ b/Luogu/P1170/P1170.cpp @@ -1,21 +1,21 @@ -#include +#include using namespace std; int gcd(int a, int b) { - if(b == 0) { + if (b == 0) { return a; } - return gcd(b, a%b); + return gcd(b, a % b); } int main() { int t; cin >> t; - while(t--) { + while (t--) { int ax, ay, bx, by; cin >> ax >> ay >> bx >> by; - cout << (gcd(abs(ax-bx), abs(ay-by)) == 1 ? "no" : "yes") << endl; + cout << (gcd(abs(ax - bx), abs(ay - by)) == 1 ? "no" : "yes") << endl; } return 0; } diff --git a/Luogu/P1181/P1181.cpp b/Luogu/P1181/P1181.cpp index 0c2e88ae..8aa5b5bf 100644 --- a/Luogu/P1181/P1181.cpp +++ b/Luogu/P1181/P1181.cpp @@ -10,8 +10,7 @@ int main() { if (sum + t > m) { ans++; sum = t; - } - else { + } else { sum += t; } } diff --git a/Luogu/P1182/P1182.cpp b/Luogu/P1182/P1182.cpp index cd56d65d..61790707 100644 --- a/Luogu/P1182/P1182.cpp +++ b/Luogu/P1182/P1182.cpp @@ -9,8 +9,7 @@ bool check(int x) { for (int i = 1; i <= n; i++) { if (tot + a[i] <= x) { tot += a[i]; - } - else { + } else { tot = a[i]; num++; } @@ -28,8 +27,7 @@ int main() { mid = l + r >> 1; if (check(mid)) { l = mid + 1; - } - else { + } else { r = mid - 1; } } diff --git a/Luogu/P1198/P1198.cpp b/Luogu/P1198/P1198.cpp index 920bd54e..76f3ac02 100644 --- a/Luogu/P1198/P1198.cpp +++ b/Luogu/P1198/P1198.cpp @@ -26,12 +26,10 @@ int main() { if (op == 'A') { a[++n] = (x + t) % d; change(n); - } - else if (op == 'Q') { + } else if (op == 'Q') { if (x == 1) { cout << (t = a[n]) << endl; - } - else { + } else { cout << (t = find(n - x + 1, n)) << endl; } } diff --git a/Luogu/P1200/P1200.cpp b/Luogu/P1200/P1200.cpp index 438872b1..f3eb1229 100644 --- a/Luogu/P1200/P1200.cpp +++ b/Luogu/P1200/P1200.cpp @@ -8,16 +8,22 @@ int main() { getline(cin, a); getline(cin, b); for (int i = 0; i < 7; i++) { - if (a[i] <= 0) break; - else us *= a[i] - 64; + if (a[i] <= 0) + break; + else + us *= a[i] - 64; } for (int i = 0; i < 7; i++) { - if (b[i] <= 0) break; - else zs *= b[i] - '@'; + if (b[i] <= 0) + break; + else + zs *= b[i] - '@'; } us %= 47; zs %= 47; - if (us == zs) cout << "GO" << endl; - else cout << "STAY" << endl; + if (us == zs) + cout << "GO" << endl; + else + cout << "STAY" << endl; return 0; } \ No newline at end of file diff --git a/Luogu/P1204/P1204.cpp b/Luogu/P1204/P1204.cpp index bc89f689..18cbd3f4 100644 --- a/Luogu/P1204/P1204.cpp +++ b/Luogu/P1204/P1204.cpp @@ -26,8 +26,7 @@ int main() { for (int i = 1; i < n; i++) { if (a[i].start <= end) { end = max(end, a[i].end); - } - else { + } else { ans1 = max(ans1, end - start); ans2 = max(ans2, a[i].start - end); start = a[i].start; diff --git a/Luogu/P1205/P1205.cpp b/Luogu/P1205/P1205.cpp index c1df97d5..50449da8 100644 --- a/Luogu/P1205/P1205.cpp +++ b/Luogu/P1205/P1205.cpp @@ -1,6 +1,6 @@ // R36572888 -#include +#include using namespace std; diff --git a/Luogu/P1216/P1216.cpp b/Luogu/P1216/P1216.cpp index ceb52dcc..c77478c6 100644 --- a/Luogu/P1216/P1216.cpp +++ b/Luogu/P1216/P1216.cpp @@ -1,23 +1,23 @@ -#include +#include using namespace std; int main() { int n, a[1005][1005], f[1005][1005]; cin >> n; - for(int i = 1 ; i <= n ; i++) { - for(int j = 1 ; j <= i ; j++) { + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= i; j++) { cin >> a[i][j]; } } f[1][1] = a[1][1]; - for(int i = 1 ; i <= n ; i++) { - for(int j = 1 ; j <= i+1 ; j++) { - f[i][j] = a[i][j] + max(f[i-1][j], f[i-1][j-1]); + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= i + 1; j++) { + f[i][j] = a[i][j] + max(f[i - 1][j], f[i - 1][j - 1]); } } int ans = -0x3f3f3f; - for(int i = 1 ; i <= n ; i++) { + for (int i = 1; i <= n; i++) { ans = max(ans, f[n][i]); } cout << ans << endl; diff --git a/Luogu/P1241/P1241.cpp b/Luogu/P1241/P1241.cpp index b472c0e2..5e3e44d3 100644 --- a/Luogu/P1241/P1241.cpp +++ b/Luogu/P1241/P1241.cpp @@ -22,12 +22,10 @@ int main() { if (st.empty() || b[st.top()] != s[i]) { if (s[i] == ')') { b[i] = '('; - } - else { + } else { b[i] = '['; } - } - else { + } else { b[st.top()] = ' '; st.pop(); } diff --git a/Luogu/P1265/P1265.cpp b/Luogu/P1265/P1265.cpp index c80be272..cd2edf3b 100644 --- a/Luogu/P1265/P1265.cpp +++ b/Luogu/P1265/P1265.cpp @@ -6,10 +6,10 @@ struct point { long long x, y; }; -int n, m; -bool v[5005]; +int n, m; +bool v[5005]; long long d[5005]; -point city[5005]; +point city[5005]; void prim() { memset(d, 0x3f, sizeof(d)); diff --git a/Luogu/P1271/P1271.cpp b/Luogu/P1271/P1271.cpp index dd0a8d8c..27c64589 100644 --- a/Luogu/P1271/P1271.cpp +++ b/Luogu/P1271/P1271.cpp @@ -1,17 +1,17 @@ // R38787626 -#include +#include using namespace std; int main() { int n, m, a[2000005]; cin >> n >> m; - for(int i = 0 ; i < m ; i++) { + for (int i = 0; i < m; i++) { cin >> a[i]; } - sort(a, a+m); - for(int i = 0 ; i < m ; i++) { + sort(a, a + m); + for (int i = 0; i < m; i++) { cout << a[i] << ' '; } cout << endl; diff --git a/Luogu/P1304/P1304.cpp b/Luogu/P1304/P1304.cpp index 76c68ab0..8d8b0353 100644 --- a/Luogu/P1304/P1304.cpp +++ b/Luogu/P1304/P1304.cpp @@ -5,7 +5,7 @@ using namespace std; bool s[10001] = {0}; -int su[1230] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973}; +int su[1230] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973}; int main() { int n; diff --git a/Luogu/P1320/P1320.cpp b/Luogu/P1320/P1320.cpp index cc8761ce..406304a6 100644 --- a/Luogu/P1320/P1320.cpp +++ b/Luogu/P1320/P1320.cpp @@ -5,33 +5,33 @@ using namespace std; int main() { - int n, c; // n: 题意中的N, c: count - char l; // 上一个出现的字符 - string s[205]; // 数组 + int n, c; // n: 题意中的N, c: count + char l; // 上一个出现的字符 + string s[205]; // 数组 n = c = 0; l = '0'; cin >> s[0]; n = s[0].size(); - for(int i = 1 ; i < n ; i++) { + for (int i = 1; i < n; i++) { cin >> s[i]; } cout << n << " "; - for(int i = 0 ; i < n ; i++) { - for(int j = 0 ; j < n ; j++) { - if(s[i][j] == l) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (s[i][j] == l) { c++; } else { - cout << c << " "; // 输出以前统计完的 - c = 1; // 坑点: 这里一定要赋值为1, 因为当前字符也算 - l = s[i][j]; // 设置当前字符为继续统计对象 + cout << c << " "; // 输出以前统计完的 + c = 1; // 坑点: 这里一定要赋值为1, 因为当前字符也算 + l = s[i][j]; // 设置当前字符为继续统计对象 } } } - cout << c << endl; // 坑点: 要输出最后一个统计 + cout << c << endl; // 坑点: 要输出最后一个统计 return 0; } diff --git a/Luogu/P1321/P1321.cpp b/Luogu/P1321/P1321.cpp index 7c5cfab0..80cbba14 100644 --- a/Luogu/P1321/P1321.cpp +++ b/Luogu/P1321/P1321.cpp @@ -6,7 +6,7 @@ using namespace std; int main() { string s; - int boy, girl; + int boy, girl; boy = girl = 0; cin >> s; @@ -17,6 +17,7 @@ int main() { 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; } diff --git a/Luogu/P1352/P1352.cpp b/Luogu/P1352/P1352.cpp index 8624a75e..974a400f 100644 --- a/Luogu/P1352/P1352.cpp +++ b/Luogu/P1352/P1352.cpp @@ -4,8 +4,8 @@ using namespace std; /* Template: 树形 DP */ vector son[6005]; -int n, l, k, f[6005][2], h[6005]; -bool v[6005]; +int n, l, k, f[6005][2], h[6005]; +bool v[6005]; void dp(int x) { int y; diff --git a/Luogu/P1359/P1359.cpp b/Luogu/P1359/P1359.cpp index bb825292..e2c72f6a 100644 --- a/Luogu/P1359/P1359.cpp +++ b/Luogu/P1359/P1359.cpp @@ -12,7 +12,7 @@ int main() { f[i] = 0x3f3f3f; } f[n] = 0; - for (int i = n-1; i >= 0; i--) { + for (int i = n - 1; i >= 0; i--) { for (int j = i + 1; j <= n; j++) { f[i] = min(f[i], f[j] + a[i][j]); } diff --git a/Luogu/P1438/P1438.cpp b/Luogu/P1438/P1438.cpp index 3b19a5f0..9ede8d5a 100644 --- a/Luogu/P1438/P1438.cpp +++ b/Luogu/P1438/P1438.cpp @@ -6,17 +6,17 @@ int n, m, op, l, r, k, d, p, a[100005]; int main() { cin >> n >> m; - for(int i = 1 ; i <= n ; i++) { + for (int i = 1; i <= n; i++) { cin >> a[i]; } - for(int i = 0 ; i < m ; i++) { + for (int i = 0; i < m; i++) { cin >> op; - if(op == 1) { + if (op == 1) { cin >> l >> r >> k >> d; - for(int j = l ; j <= r ; j++) { + for (int j = l; j <= r; j++) { a[j] += k + (j - l) * d; } - } else if(op == 2) { + } else if (op == 2) { cin >> p; cout << a[p] << endl; } diff --git a/Luogu/P1449/P1449.cpp b/Luogu/P1449/P1449.cpp index 0c6682ee..89e605c2 100644 --- a/Luogu/P1449/P1449.cpp +++ b/Luogu/P1449/P1449.cpp @@ -4,30 +4,27 @@ using namespace std; int main() { stack st; - char ch; - int a, b, t = 0; + char ch; + int a, b, t = 0; while (cin >> ch, ch != '@') { if (ch == '.') { st.push(t); t = 0; - } - else if('0' <= ch && ch <= '9') { + } else if ('0' <= ch && ch <= '9') { t *= 10; t += ch - '0'; - } - else { - b = st.top(); st.pop(); - a = st.top(); st.pop(); + } else { + b = st.top(); + st.pop(); + a = st.top(); + st.pop(); if (ch == '+') { st.push(a + b); - } - else if (ch == '-') { + } else if (ch == '-') { st.push(a - b); - } - else if (ch == '*') { + } else if (ch == '*') { st.push(a * b); - } - else if (ch == '/') { + } else if (ch == '/') { st.push(a / b); } } diff --git a/Luogu/P1531/P1531.cpp b/Luogu/P1531/P1531.cpp index a1886185..9ddf61ea 100644 --- a/Luogu/P1531/P1531.cpp +++ b/Luogu/P1531/P1531.cpp @@ -43,8 +43,7 @@ void modify(int u, int x, int d) { int mid = tr[u].l + tr[u].r >> 1; if (x <= mid) { modify(u << 1, x, d); - } - else { + } else { modify(u << 1 | 1, x, d); } pushup(u); @@ -75,8 +74,7 @@ int main() { cin >> op >> x >> y; if (op == 'U') { modify(1, x, y); - } - else if (op == 'Q') { + } else if (op == 'Q') { cout << query(1, x, y) << endl; } } diff --git a/Luogu/P1540/P1540.cpp b/Luogu/P1540/P1540.cpp index 4f7f97ab..56c3bf6a 100644 --- a/Luogu/P1540/P1540.cpp +++ b/Luogu/P1540/P1540.cpp @@ -5,10 +5,10 @@ using namespace std; int main() { - int m, n, t, f = 0, ans = 0; - bool flag = false; + int m, n, t, f = 0, ans = 0; + bool flag = false; vector memory; - queue mq; + queue mq; cin >> m >> n; for (int i = 0; i < n; i++) { cin >> t; diff --git a/Luogu/P1551/P1551.cpp b/Luogu/P1551/P1551.cpp index 8a7b9521..48d559d5 100644 --- a/Luogu/P1551/P1551.cpp +++ b/Luogu/P1551/P1551.cpp @@ -22,8 +22,7 @@ int main() { cin >> x >> y; if (find(x) == find(y)) { cout << "Yes" << endl; - } - else { + } else { cout << "No" << endl; } } diff --git a/Luogu/P1554/P1554.cpp b/Luogu/P1554/P1554.cpp index b130b053..b06a9dd5 100644 --- a/Luogu/P1554/P1554.cpp +++ b/Luogu/P1554/P1554.cpp @@ -7,13 +7,13 @@ using namespace std; int n, m, js[10]; int main() { - cin >> n >> m; - for(int i = n ; i <= m ; i++) { - for(int j = i ; j ; j /= 10) { - js[j%10]++; + cin >> n >> m; + for (int i = n; i <= m; i++) { + for (int j = i; j; j /= 10) { + js[j % 10]++; } - } - for(int i = 0 ; i < 10 ; i++) { + } + for (int i = 0; i < 10; i++) { cout << js[i] << " "; } return 0; diff --git a/Luogu/P1563/P1563.cpp b/Luogu/P1563/P1563.cpp index a05c5fcf..c12237b4 100644 --- a/Luogu/P1563/P1563.cpp +++ b/Luogu/P1563/P1563.cpp @@ -6,12 +6,12 @@ using namespace std; struct node { string name; - bool towards; + bool towards; }; int main() { // freopen("data/P1563_sample1.in", "r", stdin); - int n, m, now = 0, x, y; + int n, m, now = 0, x, y; node a[100005]; cin >> n >> m; for (int i = 0; i < n; i++) { @@ -22,16 +22,13 @@ int main() { if (a[now].towards == 0) { if (x == 0) { now = (now + n - y) % n; - } - else if (x == 1) { + } else if (x == 1) { now = (now + y) % n; } - } - else if (a[now].towards == 1) { + } else if (a[now].towards == 1) { if (x == 0) { now = (now + y) % n; - } - else if (x == 1) { + } else if (x == 1) { now = (now + n - y) % n; } } diff --git a/Luogu/P1567/P1567.cpp b/Luogu/P1567/P1567.cpp index bdef718c..1c57644b 100644 --- a/Luogu/P1567/P1567.cpp +++ b/Luogu/P1567/P1567.cpp @@ -12,8 +12,7 @@ int main() { for (int i = 1; i < n; i++) { if (a[i] > a[i - 1]) { f[i] = f[i - 1] + 1; - } - else { + } else { f[i] = 0; } } diff --git a/Luogu/P1597/P1597.cpp b/Luogu/P1597/P1597.cpp index b67ecaea..62e40b44 100644 --- a/Luogu/P1597/P1597.cpp +++ b/Luogu/P1597/P1597.cpp @@ -1,6 +1,6 @@ // https://www.luogu.com.cn/record/38654562 -#include +#include using namespace std; @@ -11,14 +11,14 @@ int main() { a = b = c = 0; cin >> s; - for(int i = 0 ; i < s.size() ; i += 5) { - cout << s[i] << ' ' << s[i+3] << ' '; - switch(s[i]) { + for (int i = 0; i < s.size(); i += 5) { + cout << s[i] << ' ' << s[i + 3] << ' '; + switch (s[i]) { case 'a': - if('0' <= s[i+3] && s[i+3] <= '9') { - a = s[i+3] - '0'; + if ('0' <= s[i + 3] && s[i + 3] <= '9') { + a = s[i + 3] - '0'; } else { - switch(s[i+3]) { + switch (s[i + 3]) { case 'a': a = a; break; @@ -32,10 +32,10 @@ int main() { } break; case 'b': - if('0' <= s[i+3] && s[i+3] <= '9') { - b = s[i+3] - '0'; + if ('0' <= s[i + 3] && s[i + 3] <= '9') { + b = s[i + 3] - '0'; } else { - switch(s[i+3]) { + switch (s[i + 3]) { case 'a': b = a; break; @@ -49,10 +49,10 @@ int main() { } break; case 'c': - if('0' <= s[i+3] && s[i+3] <= '9') { - c = s[i+3] - '0'; + if ('0' <= s[i + 3] && s[i + 3] <= '9') { + c = s[i + 3] - '0'; } else { - switch(s[i+3]) { + switch (s[i + 3]) { case 'a': c = a; break; diff --git a/Luogu/P1598/P1598.cpp b/Luogu/P1598/P1598.cpp index 6906d7a9..245b3519 100644 --- a/Luogu/P1598/P1598.cpp +++ b/Luogu/P1598/P1598.cpp @@ -6,7 +6,7 @@ using namespace std; int main() { char c; - int cnt[30]; + int cnt[30]; memset(cnt, 0x00, sizeof(cnt)); while (cin >> c) { cnt[c - 'A']++; @@ -30,8 +30,7 @@ int main() { if (cnt[j] == max) { printf("%s%c", j == 0 ? "" : " ", '*'); cnt[j]--; - } - else { + } else { printf("%s%s", j == 0 ? "" : " ", " "); } } diff --git a/Luogu/P1603/P1603.cpp b/Luogu/P1603/P1603.cpp index 06c41039..078b4526 100644 --- a/Luogu/P1603/P1603.cpp +++ b/Luogu/P1603/P1603.cpp @@ -1,98 +1,98 @@ // https://www.luogu.com.cn/record/20137358 -#include +#include using namespace std; -long long c = 0, word[6] = {0,0,0,0,0,0}, out = 0; +long long c = 0, word[6] = {0, 0, 0, 0, 0, 0}, out = 0; int getst(string s, long long &c) { - if(s=="one" || s=="a" || s=="first" || s=="another") { - word[c] = 1 ; + if (s == "one" || s == "a" || s == "first" || s == "another") { + word[c] = 1; c++; return 0; } - if(s == "two" || s == "both" || s == "second") { + if (s == "two" || s == "both" || s == "second") { word[c] = 4; c++; return 0; } - if(s == "three" || s == "third") { - word[c]=9; + if (s == "three" || s == "third") { + word[c] = 9; c++; return 0; } - if(s == "four") { + if (s == "four") { word[c] = 16; c++; return 0; } - if(s == "five") { + if (s == "five") { word[c] = 25; c++; return 0; } - if(s == "six") { + if (s == "six") { word[c] = 36; c++; return 0; } - if(s == "seven") { + if (s == "seven") { word[c] = 49; c++; return 0; } - if(s == "eight") { + if (s == "eight") { word[c] = 64; c++; return 0; } - if(s == "nine") { + if (s == "nine") { word[c] = 81; c++; return 0; - } - if(s == "eleven") { + } + if (s == "eleven") { word[c] = 21; c++; return 0; } - if(s == "twelve") { + if (s == "twelve") { word[c] = 44; c++; return 0; } - if(s == "thirteen") { + if (s == "thirteen") { word[c] = 69; c++; return 0; } - if(s == "fourteen") { + if (s == "fourteen") { word[c] = 96; c++; return 0; } - if(s == "fifteen") { + if (s == "fifteen") { word[c] = 25; c++; return 0; } - if(s == "sixteen") { + if (s == "sixteen") { word[c] = 56; c++; return 0; } - if(s == "seventeen") { + if (s == "seventeen") { word[c] = 89; c++; return 0; } - if(s == "eightteen") { + if (s == "eightteen") { word[c] = 24; c++; return 0; } - if(s == "nineteen") { + if (s == "nineteen") { word[c] = 61; c++; return 0; @@ -101,15 +101,15 @@ int getst(string s, long long &c) { int main(void) { string getit[6]; - for (int i = 0 ; i < 6 ; i++) { + for (int i = 0; i < 6; i++) { cin >> getit[i]; - if (getit[i][getit[i].size()-1] == '.') { - getit[i].erase(getit[i].size()-1,1); + if (getit[i][getit[i].size() - 1] == '.') { + getit[i].erase(getit[i].size() - 1, 1); } - getst(getit[i] , c); + getst(getit[i], c); } - sort(word , word + c); - for(int i = 0 ; i < c ; i++) { + sort(word, word + c); + for (int i = 0; i < c; i++) { out += word[i]; out *= 100; } diff --git a/Luogu/P1605/P1605.cpp b/Luogu/P1605/P1605.cpp index 4a980a15..f985c8d7 100644 --- a/Luogu/P1605/P1605.cpp +++ b/Luogu/P1605/P1605.cpp @@ -23,7 +23,7 @@ void dfs(int x, int y) { int main() { cin >> n >> m >> t >> sx >> sy >> fx >> fy; - for(int i = 0 ; i < t ; i++) { + for (int i = 0; i < t; i++) { int x, y; cin >> x >> y; vis[x][y] = -1; diff --git a/Luogu/P1614/P1614.cpp b/Luogu/P1614/P1614.cpp index 626b7d52..02df2775 100644 --- a/Luogu/P1614/P1614.cpp +++ b/Luogu/P1614/P1614.cpp @@ -5,14 +5,14 @@ using namespace std; int main() { - int n, m, a[100005], minn=100000, t=0; + int n, m, a[100005], minn = 100000, t = 0; cin >> n >> m; - for(int i = 1 ; i <= n ; i++) { + for (int i = 1; i <= n; i++) { cin >> a[i]; } - for(int i = 1 ; i <= n-m+1 ; i++) { - for(int j = 1 ; j <= m ; j++) { - t += a[i+j-1]; + for (int i = 1; i <= n - m + 1; i++) { + for (int j = 1; j <= m; j++) { + t += a[i + j - 1]; } minn = min(t, minn); t = 0; diff --git a/Luogu/P1634/P1634.cpp b/Luogu/P1634/P1634.cpp index 171aa68f..e88a38ff 100644 --- a/Luogu/P1634/P1634.cpp +++ b/Luogu/P1634/P1634.cpp @@ -1,12 +1,12 @@ -#include +#include using namespace std; int main() { - unsigned long long x, n, ans=1; + unsigned long long x, n, ans = 1; cin >> x >> n; - for(unsigned long long i = 0 ; i < n ; i++) { - ans += ans*x; + for (unsigned long long i = 0; i < n; i++) { + ans += ans * x; } cout << ans << endl; return 0; diff --git a/Luogu/P1664/P1664.cpp b/Luogu/P1664/P1664.cpp index 9e477eb1..5419b28d 100644 --- a/Luogu/P1664/P1664.cpp +++ b/Luogu/P1664/P1664.cpp @@ -32,8 +32,7 @@ int main() { if (d >= 365) { ans++; } - } - else { + } else { m++; } } diff --git a/Luogu/P1678/P1678.cpp b/Luogu/P1678/P1678.cpp index 4b72a9e4..dcbb45d0 100644 --- a/Luogu/P1678/P1678.cpp +++ b/Luogu/P1678/P1678.cpp @@ -15,11 +15,9 @@ int main() { int p = lower_bound(a, a + m, q) - a; if (p == m) { ans += q - a[m - 1]; - } - else if (p == 0) { + } else if (p == 0) { ans += a[0] - q; - } - else { + } else { ans += min(abs(a[p] - q), abs(q - a[p - 1])); } } diff --git a/Luogu/P1679/P1679.cpp b/Luogu/P1679/P1679.cpp index 98001c3f..99eb70cf 100644 --- a/Luogu/P1679/P1679.cpp +++ b/Luogu/P1679/P1679.cpp @@ -16,7 +16,7 @@ void dfs(int cnt, int k, int last) { return; } int i = last; - while (i*i*i*i <= n - cnt) { + while (i * i * i * i <= n - cnt) { i++; } while (i >= last) { diff --git a/Luogu/P1706/P1706.cpp b/Luogu/P1706/P1706.cpp index c5d0b3be..1dcbf7a1 100644 --- a/Luogu/P1706/P1706.cpp +++ b/Luogu/P1706/P1706.cpp @@ -8,10 +8,10 @@ int main() { int n, a[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; scanf("%d", &n); do { - for (int i = 0; i < n-1; i++) { + for (int i = 0; i < n - 1; i++) { printf("%5d", a[i]); } - printf("%5d\n", a[n-1]); + printf("%5d\n", a[n - 1]); } while (next_permutation(a, a + n)); return 0; } diff --git a/Luogu/P1724/P1724.cpp b/Luogu/P1724/P1724.cpp index dfc41528..855223ac 100644 --- a/Luogu/P1724/P1724.cpp +++ b/Luogu/P1724/P1724.cpp @@ -4,7 +4,7 @@ using namespace std; -int x = 0, y = 0, t = 0; +int x = 0, y = 0, t = 0; string s; int main() { diff --git a/Luogu/P1738/P1738.cpp b/Luogu/P1738/P1738.cpp index 1baf293c..a2198995 100644 --- a/Luogu/P1738/P1738.cpp +++ b/Luogu/P1738/P1738.cpp @@ -3,9 +3,9 @@ using namespace std; int main() { - int n; + int n; set disk; - string s, dir; + string s, dir; cin >> n; for (int i = 0; i < n; i++) { cin >> s; diff --git a/Luogu/P1755/P1755.cpp b/Luogu/P1755/P1755.cpp index 0867b0ac..61d4470f 100644 --- a/Luogu/P1755/P1755.cpp +++ b/Luogu/P1755/P1755.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace std; @@ -7,22 +7,22 @@ const int fib[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, int main() { int t, n; cin >> t; - while(t--) { + while (t--) { stack st; cin >> n; cout << n << "="; - for(int i = 45 ; i > 0 ; i--) { - while(n >= fib[i]) { + for (int i = 45; i > 0; i--) { + while (n >= fib[i]) { n -= fib[i]; st.push(fib[i]); } - if(n == 0) { + if (n == 0) { break; } } cout << st.top(); st.pop(); - while(!st.empty()) { + while (!st.empty()) { cout << "+" << st.top(); st.pop(); } diff --git a/Luogu/P1765/P1765.cpp b/Luogu/P1765/P1765.cpp index 06be7e99..376e2479 100644 --- a/Luogu/P1765/P1765.cpp +++ b/Luogu/P1765/P1765.cpp @@ -8,12 +8,11 @@ int num[26] = {1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, // a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v. w, x, y, z int main() { char c; - int cnt = 0; + int cnt = 0; while (scanf("%c", &c) != EOF) { if (c == ' ') { cnt++; - } - else if('a' <= c && c <= 'z') { + } else if ('a' <= c && c <= 'z') { cnt += num[c - 'a']; } // cout << c << ' ' << cnt << endl; diff --git a/Luogu/P1789/P1789.cpp b/Luogu/P1789/P1789.cpp index 869e8946..caaa85e9 100644 --- a/Luogu/P1789/P1789.cpp +++ b/Luogu/P1789/P1789.cpp @@ -5,9 +5,9 @@ int n, m, k, x, y, o, p, ans = 0; int dx1[13] = {2, 0, -2, 0, 1, 1, 1, 0, 0, 0, -1, -1, -1}; int dy1[13] = {0, 2, 0, -2, 0, 1, -1, 1, 0, -1, 0, 1, -1}; int dx2[25] = {-2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2}; -int dy2[25] = {-2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, - 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2}; + 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2}; +int dy2[25] = {-2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, + 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2}; int main() { cin >> n >> m >> k; int a[n + 5][n + 5]; diff --git a/Luogu/P1827/P1827.cpp b/Luogu/P1827/P1827.cpp index d43eec77..b35adef3 100644 --- a/Luogu/P1827/P1827.cpp +++ b/Luogu/P1827/P1827.cpp @@ -9,12 +9,12 @@ void dfs(string pre, string in) { return; } char root = pre[0]; - int k = in.find(root); + int k = in.find(root); pre.erase(pre.begin()); - string leftpre = pre.substr(0, k); + string leftpre = pre.substr(0, k); string rightpre = pre.substr(k); - string leftin = in.substr(0, k); - string rightin = in.substr(k + 1); + string leftin = in.substr(0, k); + string rightin = in.substr(k + 1); dfs(leftpre, leftin); dfs(rightpre, rightin); post.push_back(root); diff --git a/Luogu/P1865/P1865.cpp b/Luogu/P1865/P1865.cpp index db2770f6..f6fa6fcc 100644 --- a/Luogu/P1865/P1865.cpp +++ b/Luogu/P1865/P1865.cpp @@ -30,8 +30,7 @@ int main() { cin >> l >> r; if (l > m || r > m || l < 1 || r < 1) { cout << "Crossing the line" << endl; - } - else { + } else { cout << ans[r] - ans[l - 1] << endl; } } diff --git a/Luogu/P1873/P1873.cpp b/Luogu/P1873/P1873.cpp index 372a64e2..5e812eb1 100644 --- a/Luogu/P1873/P1873.cpp +++ b/Luogu/P1873/P1873.cpp @@ -2,7 +2,6 @@ using namespace std; - long long n, m, l, r, ans, a[1000005]; bool check(long long x) { @@ -25,8 +24,7 @@ int main() { long long mid = l + r >> 1; if (check(mid)) { l = (ans = mid) + 1; - } - else { + } else { r = mid - 1; } } diff --git a/Luogu/P1883/P1883.cpp b/Luogu/P1883/P1883.cpp index f6d27d6c..86b3b1f0 100644 --- a/Luogu/P1883/P1883.cpp +++ b/Luogu/P1883/P1883.cpp @@ -29,8 +29,7 @@ int main() { mid2 = r - (r - l) / 3.0; if (check(mid1) > check(mid2)) { l = mid1; - } - else { + } else { r = mid2; } } diff --git a/Luogu/P1897/P1897.cpp b/Luogu/P1897/P1897.cpp index 70873fc4..3af6291f 100644 --- a/Luogu/P1897/P1897.cpp +++ b/Luogu/P1897/P1897.cpp @@ -3,7 +3,7 @@ using namespace std; int main() { - int n, a[100005]; + int n, a[100005]; queue q; cin >> n; for (int i = 0; i < n; i++) { diff --git a/Luogu/P1898/P1898.cpp b/Luogu/P1898/P1898.cpp index 0a6f2cf7..96958301 100644 --- a/Luogu/P1898/P1898.cpp +++ b/Luogu/P1898/P1898.cpp @@ -3,7 +3,7 @@ using namespace std; string s; -int st, cnt = 0, a[1000005], ans[1000005]; +int st, cnt = 0, a[1000005], ans[1000005]; int main() { cin >> s >> st; @@ -23,11 +23,9 @@ int main() { } if (ans[3] == 1 && ans[2] == 0 && ans[1] == 0) { 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; - } - else { + } else { cout << (ans[1] + ans[2]) % 10 << endl; } return 0; diff --git a/Luogu/P1908/P1908.cpp b/Luogu/P1908/P1908.cpp index b60045fb..e541506c 100644 --- a/Luogu/P1908/P1908.cpp +++ b/Luogu/P1908/P1908.cpp @@ -13,8 +13,7 @@ void merge_sort(long long a[], long long l, long long r) { while (i <= mid && j <= r) { if (a[i] <= a[j]) { t[k++] = a[i++]; - } - else { + } else { t[k++] = a[j++]; ans += (mid - i + 1); } diff --git a/Luogu/P1928/P1928.cpp b/Luogu/P1928/P1928.cpp index 47eb9ac5..729251ec 100644 --- a/Luogu/P1928/P1928.cpp +++ b/Luogu/P1928/P1928.cpp @@ -5,9 +5,9 @@ using namespace std; string cnm() { - int n; - char ch; - string s = ""; + int n; + char ch; + string s = ""; string str = ""; while (cin >> ch) { @@ -17,11 +17,9 @@ string cnm() { while (n--) { s += str; } - } - else if (ch == ']') { + } else if (ch == ']') { return s; - } - else { + } else { s += ch; } } diff --git a/Luogu/P1947/P1947.cpp b/Luogu/P1947/P1947.cpp index 8a46a631..c1c847a1 100644 --- a/Luogu/P1947/P1947.cpp +++ b/Luogu/P1947/P1947.cpp @@ -7,8 +7,7 @@ extern "C" int Chtholly(int n, int OvO) { if (Seniorious(mid) >= 0) { ans = mid; r = mid - 1; - } - else { + } else { l = mid + 1; } mid = l + r >> 1; diff --git a/Luogu/P1983/P1983.cpp b/Luogu/P1983/P1983.cpp index d9c0bfe7..d1e6c948 100644 --- a/Luogu/P1983/P1983.cpp +++ b/Luogu/P1983/P1983.cpp @@ -2,7 +2,7 @@ using namespace std; -int n, m, k, ans, l, a[1005], d[1005], c[1005][1005], f[1005]; +int n, m, k, ans, l, a[1005], d[1005], c[1005][1005], f[1005]; bool v[1005][1005]; int dfs(int x) { @@ -26,14 +26,13 @@ int main() { for (int j = a[1]; j < a[a[0]]; j++) { if (a[l] == j) { l++; - } - else { + } else { for (int k = 1; k <= a[0]; k++) { if (!v[a[k]][j]) { int t = a[k]; c[t][0]++; c[t][c[t][0]] = j; - v[t][j] = 1; + v[t][j] = 1; } } } diff --git a/Luogu/P2023/P2023.cpp b/Luogu/P2023/P2023.cpp index a632c36b..bff9a5bf 100644 --- a/Luogu/P2023/P2023.cpp +++ b/Luogu/P2023/P2023.cpp @@ -84,12 +84,10 @@ signed main() { if (op == 1) { cin >> k; modify(1, x, y, k, 0); - } - else if (op == 2) { + } else if (op == 2) { cin >> k; modify(1, x, y, 1, k); - } - else if (op == 3) { + } else if (op == 3) { cout << query(1, x, y) % p << endl; } } diff --git a/Luogu/P2068/P2068.cpp b/Luogu/P2068/P2068.cpp index b0f26b39..b87d40f2 100644 --- a/Luogu/P2068/P2068.cpp +++ b/Luogu/P2068/P2068.cpp @@ -37,8 +37,10 @@ void modify(int u, int x, int d) { return; } int mid = tr[u].l + tr[u].r >> 1; - if (x <= mid) modify(u << 1, x, d); - else modify(u << 1 | 1, x, d); + if (x <= mid) + modify(u << 1, x, d); + else + modify(u << 1 | 1, x, d); pushup(u); } @@ -60,8 +62,7 @@ int main() { cin >> op >> a >> b; if (op == 'x') { modify(1, a, b); - } - else if (op == 'y') { + } else if (op == 'y') { cout << query(1, a, b) << endl; } } diff --git a/Luogu/P2073/P2073.cpp b/Luogu/P2073/P2073.cpp index 31a0b485..0332e5ff 100644 --- a/Luogu/P2073/P2073.cpp +++ b/Luogu/P2073/P2073.cpp @@ -21,18 +21,16 @@ struct node { int main() { long long op; - node ans; + node ans; set a; while (cin >> op, op != -1) { if (op == 1) { long long w, c; cin >> w >> c; a.insert(node(w, c)); - } - else if (op == 2 && !a.empty()) { + } else if (op == 2 && !a.empty()) { a.erase(--a.end()); - } - else if (op == 3 && !a.empty()) { + } else if (op == 3 && !a.empty()) { a.erase(a.begin()); } } diff --git a/Luogu/P2084/P2084.cpp b/Luogu/P2084/P2084.cpp index 3f04aa5e..0ee7f5b9 100644 --- a/Luogu/P2084/P2084.cpp +++ b/Luogu/P2084/P2084.cpp @@ -8,7 +8,7 @@ string s; int main() { cin >> m >> s; for (int i = 0; i < s.size(); i++) { - if(s[i] == '0') { + if (s[i] == '0') { continue; } if (i != 0) { diff --git a/Luogu/P2097/P2097.cpp b/Luogu/P2097/P2097.cpp index 1eafd04a..71ae5037 100644 --- a/Luogu/P2097/P2097.cpp +++ b/Luogu/P2097/P2097.cpp @@ -3,7 +3,7 @@ using namespace std; vector l[100010]; -int n, m, f, s, ans, pd[100010]; +int n, m, f, s, ans, pd[100010]; void dfs(int x) { for (int y = 0; y < l[x].size(); y++) { diff --git a/Luogu/P2249/P2249.cpp b/Luogu/P2249/P2249.cpp index d1c34472..48b37506 100644 --- a/Luogu/P2249/P2249.cpp +++ b/Luogu/P2249/P2249.cpp @@ -3,7 +3,7 @@ using namespace std; int main() { - int n, t, m; + int n, t, m; vector nums; cin >> n >> m; for (int i = 0; i < n; i++) { @@ -15,8 +15,7 @@ int main() { vector::iterator it = lower_bound(nums.begin(), nums.end(), t); if (*it == t) { cout << it - nums.begin() + 1 << ' '; - } - else { + } else { cout << "-1 "; } } diff --git a/Luogu/P2357/P2357.cpp b/Luogu/P2357/P2357.cpp index 14ea860c..cd7a7ec2 100644 --- a/Luogu/P2357/P2357.cpp +++ b/Luogu/P2357/P2357.cpp @@ -80,20 +80,16 @@ int main() { if (op == 1) { cin >> x >> y >> k; modify(1, x, y, k); - } - else if(op == 2) { + } else if (op == 2) { cin >> k; modify(1, 1, 1, k); - } - else if(op == 3) { + } else if (op == 3) { cin >> k; modify(1, 1, 1, -k); - } - else if(op == 4) { + } else if (op == 4) { cin >> x >> y; cout << query(1, x, y) << endl; - } - else if(op == 5) { + } else if (op == 5) { cout << query(1, 1, 1) << endl; } } diff --git a/Luogu/P2368/P2368.cpp b/Luogu/P2368/P2368.cpp index 324bb9eb..e181a83f 100644 --- a/Luogu/P2368/P2368.cpp +++ b/Luogu/P2368/P2368.cpp @@ -1,19 +1,17 @@ -#include +#include using namespace std; int main() { int n; cin >> n; - if(n <= 8) { + if (n <= 8) { cout << 0 << endl; - } - else if(n == 9) { + } else if (n == 9) { cout << 8 << endl; - } - else { + } else { cout << 72; - for(int i = 10 ; i < n ; i++) { + for (int i = 10; i < n; i++) { cout << 0; } cout << endl; diff --git a/Luogu/P2369/P2369.cpp b/Luogu/P2369/P2369.cpp index 73effc84..025b4434 100644 --- a/Luogu/P2369/P2369.cpp +++ b/Luogu/P2369/P2369.cpp @@ -4,7 +4,7 @@ using namespace std; int main() { short a[1000005]; - int n, m; + int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a[i]; diff --git a/Luogu/P2404/P2404.cpp b/Luogu/P2404/P2404.cpp index 1612a413..c7ae1bb7 100644 --- a/Luogu/P2404/P2404.cpp +++ b/Luogu/P2404/P2404.cpp @@ -7,10 +7,10 @@ int n, a[10]; void dfs(int x, int depth, int last) { if (x > n) return; if (x == n) { - for(int i = 1 ; i < depth - 1 ; i++) { + for (int i = 1; i < depth - 1; i++) { cout << a[i] << '+'; } - cout << a[depth-1] << endl; + cout << a[depth - 1] << endl; return; } for (int i = last; i < n; i++) { diff --git a/Luogu/P2433/P2433.cpp b/Luogu/P2433/P2433.cpp index c3d922ee..a9f4f641 100644 --- a/Luogu/P2433/P2433.cpp +++ b/Luogu/P2433/P2433.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace std; @@ -7,51 +7,38 @@ int main() { cin >> T; if (T == 1) { cout << "I love Luogu!"; - } - else if (T == 2) { + } else if (T == 2) { cout << 2 + 4 << " " << 10 - 2 - 4; - } - else if (T == 3) { + } else if (T == 3) { cout << 3 << endl << 12 << endl << 2 << endl; - } - else if (T == 4) { + } else if (T == 4) { printf("%.3lf\n", 500.0 / 3.0); - } - else if (T == 5) { + } else if (T == 5) { cout << 15 << endl; - } - else if (T == 6) { + } else if (T == 6) { cout << sqrt(6 * 6 + 9 * 9) << endl; - } - else if (T == 7) { + } else if (T == 7) { cout << 110 << endl << 90 << endl << 0 << endl; - } - else if (T == 8) { + } else if (T == 8) { cout << 3.141593 * 5 * 2 << endl << 3.141593 * 5 * 5 << endl << 4.0 / 3 * 3.141593 * 5 * 5 * 5 << endl; - } - else if (T == 9) { + } else if (T == 9) { cout << 22 << endl; - } - else if (T == 10) { + } else if (T == 10) { cout << 9 << endl; - } - else if (T == 11) { + } else if (T == 11) { cout << 100.0 / (8 - 5) << endl; - } - else if (T == 12) { + } else if (T == 12) { cout << 13 << 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; - } - else if (T == 14) { + } else if (T == 14) { cout << 50 << endl; } return 0; diff --git a/Luogu/P2550/P2550.cpp b/Luogu/P2550/P2550.cpp index 72fe6826..e1ef918a 100644 --- a/Luogu/P2550/P2550.cpp +++ b/Luogu/P2550/P2550.cpp @@ -8,24 +8,23 @@ int n, win[7], lottery[7], sum[10], c; int main() { cin >> n; - for(int i = 0 ; i < 7 ; i++) { + for (int i = 0; i < 7; i++) { cin >> win[i]; } - for(int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { c = 0; - for(int j = 0 ; j < 7 ; j++) { + for (int j = 0; j < 7; j++) { cin >> lottery[j]; - for(int p = 0 ; p < 7 ; p++) { - if(lottery[j] == win[p]) c++; + for (int p = 0; p < 7; p++) { + if (lottery[j] == win[p]) c++; } } // cout << c << ' '; // debug sum[c]++; } // cout << endl; // debug - for(int i = 7 ; i > 0 ; i--) { + for (int i = 7; i > 0; i--) { cout << sum[i] << ' '; } return 0; } - diff --git a/Luogu/P2574/P2574.cpp b/Luogu/P2574/P2574.cpp index 5a765aeb..29bd4c13 100644 --- a/Luogu/P2574/P2574.cpp +++ b/Luogu/P2574/P2574.cpp @@ -81,8 +81,7 @@ int main() { cin >> op >> x >> y; if (op == 0) { modify(1, x, y); - } - else if (op == 1) { + } else if (op == 1) { cout << query(1, x, y) << endl; } } diff --git a/Luogu/P2640/P2640.cpp b/Luogu/P2640/P2640.cpp index 2a8f4c5b..1db0c8c6 100644 --- a/Luogu/P2640/P2640.cpp +++ b/Luogu/P2640/P2640.cpp @@ -21,7 +21,7 @@ bool isPrime(int x) { } int main() { - int n, k; + int n, k; bool flag = false; cin >> n >> k; for (int i = 2; i + k <= n; i++) { diff --git a/Luogu/P2676/P2676.cpp b/Luogu/P2676/P2676.cpp index 94c62d7e..11db2748 100644 --- a/Luogu/P2676/P2676.cpp +++ b/Luogu/P2676/P2676.cpp @@ -1,19 +1,19 @@ // R38819026 -#include +#include using namespace std; int main() { - int n, h[20005], b, sum=0, i; + int n, h[20005], b, sum = 0, i; cin >> n >> b; - for(i = 0 ; i < n ; i++) { + for (i = 0; i < n; i++) { cin >> h[i]; } - sort(h, h+n); - while(sum < b) { + sort(h, h + n); + while (sum < b) { sum += h[--i]; } - cout << n-i << endl; + cout << n - i << endl; return 0; } diff --git a/Luogu/P2678/P2678.cpp b/Luogu/P2678/P2678.cpp index 0a542fc3..df5bdacb 100644 --- a/Luogu/P2678/P2678.cpp +++ b/Luogu/P2678/P2678.cpp @@ -21,7 +21,7 @@ int main() { for (int i = 1; i <= n; i++) { cin >> a[i]; } - a[n+1] = r; + a[n + 1] = r; l = 1; while (l <= r) { mid = l + r >> 1; diff --git a/Luogu/P2689/P2689.cpp b/Luogu/P2689/P2689.cpp index dd3d4838..8b166f2e 100644 --- a/Luogu/P2689/P2689.cpp +++ b/Luogu/P2689/P2689.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace std; @@ -6,25 +6,22 @@ int main() { int x1, y1, x2, y2, t, ans = 0; char c; cin >> x1 >> y1 >> x2 >> y2 >> t; - for(int i = 1 ; i <= t ; i++) { + for (int i = 1; i <= t; i++) { cin >> c; - if(c == 'E' && y1 < y2) { + if (c == 'E' && y1 < y2) { y1++; ans++; - } - else if(c == 'W' && y1 > y2) { + } else if (c == 'W' && y1 > y2) { y1--; ans++; - } - else if(c == 'N' && x1 < x2) { + } else if (c == 'N' && x1 < x2) { x1++; ans++; - } - else if(c == 'S' && x1 > x2) { + } else if (c == 'S' && x1 > x2) { x1--; ans++; } - if(x1 == x2 && y1 == y2) { + if (x1 == x2 && y1 == y2) { cout << ans << endl; return 0; } diff --git a/Luogu/P2846/P2846.cpp b/Luogu/P2846/P2846.cpp index 7ed57b8c..e1c18864 100644 --- a/Luogu/P2846/P2846.cpp +++ b/Luogu/P2846/P2846.cpp @@ -66,11 +66,11 @@ int query(int u, int l, int r) { int main() { cin >> n >> m; build(1, 1, n); - for(int i = 0 ; i < m ; i++) { + for (int i = 0; i < m; i++) { cin >> op >> s >> e; - if(op == 0) { + if (op == 0) { modify(1, s, e); - } else if(op == 1) { + } else if (op == 1) { cout << query(1, s, e) << endl; } } diff --git a/Luogu/P2911/P2911.cpp b/Luogu/P2911/P2911.cpp index 90a8bdac..d97a1c68 100644 --- a/Luogu/P2911/P2911.cpp +++ b/Luogu/P2911/P2911.cpp @@ -8,14 +8,14 @@ int s1, s2, s3; int main() { scanf("%d%d%d", &s1, &s2, &s3); - if(s3 > s1 + s2) { - printf("%d", s1+s2+1); - } else if(s2 > s1 + s3) { - printf("%d", s1+s3+1); - } else if(s1 > s3 + s2) { - printf("%d", s3+s2+1); + if (s3 > s1 + s2) { + printf("%d", s1 + s2 + 1); + } else if (s2 > s1 + s3) { + printf("%d", s1 + s3 + 1); + } else if (s1 > s3 + s2) { + printf("%d", s3 + s2 + 1); } else { - printf("%d", (s1+s2+s3+3)/2); + printf("%d", (s1 + s2 + s3 + 3) / 2); } return 0; } diff --git a/Luogu/P3150/P3150.cpp b/Luogu/P3150/P3150.cpp index f7312a63..7d25dfd8 100644 --- a/Luogu/P3150/P3150.cpp +++ b/Luogu/P3150/P3150.cpp @@ -9,8 +9,7 @@ int main() { cin >> t; if (t % 2 == 0) { cout << "pb wins" << endl; - } - else { + } else { cout << "zs wins" << endl; } } diff --git a/Luogu/P3156/P3156.cpp b/Luogu/P3156/P3156.cpp index 45100f7c..d765892a 100644 --- a/Luogu/P3156/P3156.cpp +++ b/Luogu/P3156/P3156.cpp @@ -12,7 +12,7 @@ int main() { } for (int i = 0; i < m; i++) { cin >> q; - cout << a[q-1] << endl; + cout << a[q - 1] << endl; } return 0; } diff --git a/Luogu/P3367/P3367.cpp b/Luogu/P3367/P3367.cpp index 2181e65d..5c8340e2 100644 --- a/Luogu/P3367/P3367.cpp +++ b/Luogu/P3367/P3367.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace std; @@ -11,15 +11,14 @@ int find(int x) { int main() { int n, m, z, x, y; cin >> n >> m; - for(int i = 0; i < n ; i++) { + for (int i = 0; i < n; i++) { f[i] = i; } - while(m--) { + while (m--) { cin >> z >> x >> y; - if(z == 1) { + if (z == 1) { f[find(x)] = find(y); - } - else { + } else { cout << (find(x) == find(y) ? "Y" : "N") << endl; } } diff --git a/Luogu/P3368/P3368.cpp b/Luogu/P3368/P3368.cpp index 12b4d0fe..03e77734 100644 --- a/Luogu/P3368/P3368.cpp +++ b/Luogu/P3368/P3368.cpp @@ -81,8 +81,7 @@ int main() { if (op == 1) { scanf("%d%d", &y, &k); modify(1, x, y, k); - } - else if (op == 2) { + } else if (op == 2) { printf("%d\n", query(1, x, x)); } } diff --git a/Luogu/P3369/P3369.cpp b/Luogu/P3369/P3369.cpp index 5ae1247b..ae3158d9 100644 --- a/Luogu/P3369/P3369.cpp +++ b/Luogu/P3369/P3369.cpp @@ -3,27 +3,22 @@ using namespace std; int main() { - int n, x, opt; + int n, x, opt; vector a; cin >> n; for (int i = 0; i < n; i++) { cin >> opt >> x; if (opt == 1) { 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)); - } - else if (opt == 3) { + } else if (opt == 3) { 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; - } - else if (opt == 5) { + } else if (opt == 5) { 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; } } diff --git a/Luogu/P3372/P3372.cpp b/Luogu/P3372/P3372.cpp index 4d756890..a48d2091 100644 --- a/Luogu/P3372/P3372.cpp +++ b/Luogu/P3372/P3372.cpp @@ -111,8 +111,7 @@ int main() { if (op == 1) { cin >> k; modify(1, x, y, k); - } - else if (op == 2) { + } else if (op == 2) { cout << query(1, x, y) << endl; } } diff --git a/Luogu/P3373/P3373.cpp b/Luogu/P3373/P3373.cpp index 6677f05e..37ff1279 100644 --- a/Luogu/P3373/P3373.cpp +++ b/Luogu/P3373/P3373.cpp @@ -118,12 +118,10 @@ signed main() { if (op == 1) { cin >> k; modify(1, x, y, k, 0); - } - else if (op == 2) { + } else if (op == 2) { cin >> k; modify(1, x, y, 1, k); - } - else if (op == 3) { + } else if (op == 3) { cout << query(1, x, y) % p << endl; } } diff --git a/Luogu/P3374/P3374.cpp b/Luogu/P3374/P3374.cpp index 856ece7b..3782a155 100644 --- a/Luogu/P3374/P3374.cpp +++ b/Luogu/P3374/P3374.cpp @@ -40,8 +40,7 @@ void change(int u, int x, int d) { int mid = tr[u].l + tr[u].r >> 1; if (x <= mid) { change(u << 1, x, d); - } - else { + } else { change(u << 1 | 1, x, d); } pushup(u); @@ -68,8 +67,7 @@ int main() { cin >> op >> x >> y; if (op == 1) { change(1, x, y); - } - else if (op == 2) { + } else if (op == 2) { cout << query(1, x, y) << endl; } } diff --git a/Luogu/P3378/P3378.cpp b/Luogu/P3378/P3378.cpp index 0fc7930f..19329803 100644 --- a/Luogu/P3378/P3378.cpp +++ b/Luogu/P3378/P3378.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace std; @@ -6,18 +6,16 @@ int main() { priority_queue, greater > q; int n; cin >> n; - while(n--) { + while (n--) { int op; cin >> op; - if(op == 1) { + if (op == 1) { int x; cin >> x; q.push(x); - } - else if(op == 2) { + } else if (op == 2) { cout << q.top() << endl; - } - else if(op == 3) { + } else if (op == 3) { q.pop(); } } diff --git a/Luogu/P3382/P3382.cpp b/Luogu/P3382/P3382.cpp index f8821546..250bba1b 100644 --- a/Luogu/P3382/P3382.cpp +++ b/Luogu/P3382/P3382.cpp @@ -24,8 +24,7 @@ int main() { mid2 = r - (r - l) / 3.0; if (f(mid1) > f(mid2)) { r = mid2; - } - else { + } else { l = mid1; } } diff --git a/Luogu/P3391/P3391.cpp b/Luogu/P3391/P3391.cpp index 71009813..9947b3d4 100644 --- a/Luogu/P3391/P3391.cpp +++ b/Luogu/P3391/P3391.cpp @@ -4,7 +4,7 @@ using namespace std; int main() { vector a; - int n, m, l, r; + int n, m, l, r; scanf("%d%d", &n, &m); for (int i = 0; i <= n; i++) { a.push_back(i); diff --git a/Luogu/P3613/P3613.cpp b/Luogu/P3613/P3613.cpp index 494cdfd6..ba6b42e8 100644 --- a/Luogu/P3613/P3613.cpp +++ b/Luogu/P3613/P3613.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace std; @@ -6,21 +6,21 @@ int main() { map > m; int n, q, t, i, j, k; cin >> n >> q; - while(q--) { + while (q--) { cin >> t >> i >> j; - if(t == 1) { + if (t == 1) { cin >> k; - if(k == 0) { - if(m.count(i) && m[i].count(j)) { + if (k == 0) { + if (m.count(i) && m[i].count(j)) { m[i].erase(k); - if(m[i].empty()) { + if (m[i].empty()) { m.erase(i); } } } else { m[i][j] = k; } - } else if(t == 2) { + } else if (t == 2) { cout << m[i][j] << endl; } } diff --git a/Luogu/P3717/P3717.cpp b/Luogu/P3717/P3717.cpp index c74dde3d..d9a5d224 100644 --- a/Luogu/P3717/P3717.cpp +++ b/Luogu/P3717/P3717.cpp @@ -17,9 +17,9 @@ int main() { } } } - for(int i = 1 ; i <= n ; i++) { - for(int j = 1 ; j <= n ; j++) { - if(vis[i][j]) { + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { + if (vis[i][j]) { ans++; } } diff --git a/Luogu/P3741/P3741.cpp b/Luogu/P3741/P3741.cpp index f1af911d..ec55970d 100644 --- a/Luogu/P3741/P3741.cpp +++ b/Luogu/P3741/P3741.cpp @@ -13,7 +13,7 @@ int count(string str) { } int main() { - int n, max; + int n, max; string str; cin >> n >> str; @@ -23,8 +23,7 @@ int main() { for (int i = 0; i < str.size(); i++) { if (str[i] == 'V') { str[i] = 'K'; - } - else { + } else { str[i] = 'V'; } @@ -35,8 +34,7 @@ int main() { } if (str[i] == 'V') { str[i] = 'K'; - } - else { + } else { str[i] = 'V'; } } diff --git a/Luogu/P3853/P3853.cpp b/Luogu/P3853/P3853.cpp index 70b2adca..0fe97f55 100644 --- a/Luogu/P3853/P3853.cpp +++ b/Luogu/P3853/P3853.cpp @@ -22,8 +22,10 @@ int main() { } while (l < r) { int mid = l + r >> 1; - if (check(mid)) r = mid; - else l = mid + 1; + if (check(mid)) + r = mid; + else + l = mid + 1; } cout << l << endl; return 0; diff --git a/Luogu/P3871/P3871.cpp b/Luogu/P3871/P3871.cpp index bc24c7e9..fd5e3c37 100644 --- a/Luogu/P3871/P3871.cpp +++ b/Luogu/P3871/P3871.cpp @@ -1,24 +1,23 @@ -#include +#include using namespace std; int main() { - int n,m, t; + int n, m, t; string op; vector nums; cin >> n; - for(int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { cin >> t; nums.insert(lower_bound(nums.begin(), nums.end(), t), t); } cin >> m; - for(int i = 0 ; i < m ; i++) { + for (int i = 0; i < m; i++) { cin >> op; - if(op == "add") { + if (op == "add") { cin >> t; nums.insert(lower_bound(nums.begin(), nums.end(), t), t); - } - else { + } else { cout << nums[nums.size() / 2 - (nums.size() & 1 ^ 1)] << endl; } } diff --git a/Luogu/P3879/P3879.cpp b/Luogu/P3879/P3879.cpp index ce40d773..2e2c60f5 100644 --- a/Luogu/P3879/P3879.cpp +++ b/Luogu/P3879/P3879.cpp @@ -19,8 +19,7 @@ int main() { cin >> s; if (!m.count(s)) { cout << endl; - } - else { + } else { for (set::iterator it = m[s].begin(); it != --m[s].end(); it++) { cout << *it << ' '; } diff --git a/Luogu/P3912/P3912.cpp b/Luogu/P3912/P3912.cpp index 10f0ac21..a644da36 100644 --- a/Luogu/P3912/P3912.cpp +++ b/Luogu/P3912/P3912.cpp @@ -5,13 +5,13 @@ using namespace std; int main() { int n; cin >> n; - int s = n-1; + int s = n - 1; bool prime[100000005]; memset(prime, 0, sizeof(prime)); - for(int i = 2 ; i*i <= n ; i++) { - if(!prime[i]) { - for(int j = i*2 ; j <= n ; j+= i) { - if(!prime[j]) { + for (int i = 2; i * i <= n; i++) { + if (!prime[i]) { + for (int j = i * 2; j <= n; j += i) { + if (!prime[j]) { prime[j] = true; s--; } diff --git a/Luogu/P3916/P3916.cpp b/Luogu/P3916/P3916.cpp index 8f468419..611cbb5a 100644 --- a/Luogu/P3916/P3916.cpp +++ b/Luogu/P3916/P3916.cpp @@ -2,7 +2,7 @@ using namespace std; -int n, m, u, v, a[100010]; +int n, m, u, v, a[100010]; vector g[100010]; void dfs(int x, int d) { diff --git a/Luogu/P4325/P4325.cpp b/Luogu/P4325/P4325.cpp index 65898b89..4e4bb98e 100644 --- a/Luogu/P4325/P4325.cpp +++ b/Luogu/P4325/P4325.cpp @@ -1,13 +1,13 @@ -#include +#include using namespace std; int main() { int t; set s; - for(int i = 0 ; i < 10 ; i++) { + for (int i = 0; i < 10; i++) { cin >> t; - s.insert(t%42); + s.insert(t % 42); } cout << s.size() << endl; return 0; diff --git a/Luogu/P4327/P4327.cpp b/Luogu/P4327/P4327.cpp index 2de43d34..316c56a6 100644 --- a/Luogu/P4327/P4327.cpp +++ b/Luogu/P4327/P4327.cpp @@ -13,14 +13,12 @@ int main() { ans[2] += (string) "." + s[i] + ".*"; ans[3] += "*.*."; ans[4] += ".*.."; - } - else { + } else { ans[0] += ".#.."; ans[1] += "#.#."; if ((i + 1) % 3 == 2 && i + 1 != s.size()) { ans[2] += (string) "." + s[i] + ".*"; - } - else { + } else { ans[2] += (string) "." + s[i] + ".#"; } ans[3] += "#.#."; diff --git a/Luogu/P4445/P4445.cpp b/Luogu/P4445/P4445.cpp index d89ed420..5ef100e1 100644 --- a/Luogu/P4445/P4445.cpp +++ b/Luogu/P4445/P4445.cpp @@ -1,16 +1,16 @@ -#include +#include using namespace std; int main() { int n, a[100005]; - long long ans=0; + long long ans = 0; cin >> n; - for(int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { cin >> a[i]; } - for(int i = 1 ; i < n ; i++) { - ans += max(a[i], a[i-1]); + for (int i = 1; i < n; i++) { + ans += max(a[i], a[i - 1]); } cout << ans << endl; return 0; diff --git a/Luogu/P4449/P4449.cpp b/Luogu/P4449/P4449.cpp index f4febcdf..6422bcea 100644 --- a/Luogu/P4449/P4449.cpp +++ b/Luogu/P4449/P4449.cpp @@ -28,8 +28,7 @@ void euler(long long n) { if (i % pri[j] == 0) { f[i * pri[j]] = f[i] * powk[pri[j]] % mod; break; - } - else { + } else { f[i * pri[j]] = f[i] * f[pri[j]] % mod; } } diff --git a/Luogu/P4588/P4588.cpp b/Luogu/P4588/P4588.cpp index 4b7b1b46..404df876 100644 --- a/Luogu/P4588/P4588.cpp +++ b/Luogu/P4588/P4588.cpp @@ -42,8 +42,7 @@ void modify(int u, int x, int v) { int mid = tr[u].l + tr[u].r >> 1; if (x <= mid) { modify(u << 1, x, v); - } - else { + } else { modify(u << 1 | 1, x, v); } pushup(u); @@ -58,8 +57,7 @@ int main() { cin >> op >> m; if (op == 1) { modify(1, i, m); - } - else if (op == 2) { + } else if (op == 2) { modify(1, m, 1); } cout << tr[1].s << endl; diff --git a/Luogu/P4715/P4715.cpp b/Luogu/P4715/P4715.cpp index ca4091cd..337226ee 100644 --- a/Luogu/P4715/P4715.cpp +++ b/Luogu/P4715/P4715.cpp @@ -3,7 +3,7 @@ using namespace std; int main() { - int n, t; + int n, t; queue> q; cin >> n; n = 1 << n; diff --git a/Luogu/P4913/P4913.cpp b/Luogu/P4913/P4913.cpp index 459502e1..62449737 100644 --- a/Luogu/P4913/P4913.cpp +++ b/Luogu/P4913/P4913.cpp @@ -7,11 +7,9 @@ int n, l[1000005], r[1000005]; int dfs(int now, int cnt) { if (l[now] == 0 && r[now] == 0) { return cnt; - } - else if (l[now] == 0) { + } else if (l[now] == 0) { return dfs(r[now], cnt + 1); - } - else if (r[now] == 0) { + } else if (r[now] == 0) { return dfs(l[now], cnt + 1); } return max(dfs(l[now], cnt + 1), dfs(r[now], cnt + 1)); diff --git a/Luogu/P4939/P4939.cpp b/Luogu/P4939/P4939.cpp index b7c918c7..f77a81f4 100644 --- a/Luogu/P4939/P4939.cpp +++ b/Luogu/P4939/P4939.cpp @@ -30,8 +30,7 @@ int main() { cin >> y; add(x, 1); add(y + 1, -1); - } - else if (op == 1) { + } else if (op == 1) { cout << sum(x) << endl; } } diff --git a/Luogu/P5057/P5057.cpp b/Luogu/P5057/P5057.cpp index 858e5873..fc2319fe 100644 --- a/Luogu/P5057/P5057.cpp +++ b/Luogu/P5057/P5057.cpp @@ -62,8 +62,7 @@ int main() { if (t == 1) { cin >> y; change(1, x, y); - } - else { + } else { cout << query(1, x) << endl; } } diff --git a/Luogu/P5143/P5143.cpp b/Luogu/P5143/P5143.cpp index d5547544..661cd473 100644 --- a/Luogu/P5143/P5143.cpp +++ b/Luogu/P5143/P5143.cpp @@ -25,12 +25,12 @@ int main() { node a[50005]; double ans = 0.000; scanf("%d", &n); - for(int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z); } - sort(a, a+n, cmp); - for(int i = 1 ; i < n ;i++) { - ans += ed(a[i-1], a[i]); + sort(a, a + n, cmp); + for (int i = 1; i < n; i++) { + ans += ed(a[i - 1], a[i]); } printf("%.3lf", ans); return 0; diff --git a/Luogu/P5250/P5250.cpp b/Luogu/P5250/P5250.cpp index c56df45b..d027fa4e 100644 --- a/Luogu/P5250/P5250.cpp +++ b/Luogu/P5250/P5250.cpp @@ -4,44 +4,37 @@ using namespace std; int main() { map m; - int i, j, n, x, y; + int i, j, n, x, y; cin >> n; for (i = 0; i < n; i++) { cin >> x >> y; if (x == 1) { if (m.count(y)) { cout << "Already Exist" << endl; - } - else { + } else { m[y] = 1; } - } - else { + } else { if (m.empty()) { cout << "Empty" << endl; - } - else if (m.count(y)) { + } else if (m.count(y)) { m.erase(y); cout << y << endl; - } - else { - m[y] = 1; - map::iterator it = m.find(y); + } else { + m[y] = 1; + map::iterator it = m.find(y); map::iterator it2 = it; it++; if (it2 == m.begin()) { cout << it->first << endl; m.erase(it); - } - else if (it == m.end()) { + } else if (it == m.end()) { cout << (--it2)->first << endl; m.erase(it2); - } - else if (y - (--it2)->first > it->first - y) { + } else if (y - (--it2)->first > it->first - y) { cout << it->first << endl; m.erase(it); - } - else { + } else { cout << it2->first << endl; m.erase(it2); } diff --git a/Luogu/P5266/P5266.cpp b/Luogu/P5266/P5266.cpp index b77210bf..9dfd0c3f 100644 --- a/Luogu/P5266/P5266.cpp +++ b/Luogu/P5266/P5266.cpp @@ -3,8 +3,8 @@ using namespace std; int main() { - int n, q, a, b; - string s; + int n, q, a, b; + string s; map students; cin >> n; while (n--) { @@ -13,27 +13,22 @@ int main() { cin >> s >> b; students[s] = b; cout << "OK" << endl; - } - else if (q == 2) { + } else if (q == 2) { cin >> s; if (students.find(s) != students.end()) { cout << students[s] << endl; - } - else { + } else { cout << "Not found" << endl; } - } - else if (q == 3) { + } else if (q == 3) { cin >> s; if (students.find(s) != students.end()) { students.erase(s); cout << "Deleted successfully" << endl; - } - else { + } else { cout << "Not found" << endl; } - } - else if(q == 4) { + } else if (q == 4) { cout << students.size() << endl; } } diff --git a/Luogu/P5318/P5318.cpp b/Luogu/P5318/P5318.cpp index 4456a5ab..e2888cd5 100644 --- a/Luogu/P5318/P5318.cpp +++ b/Luogu/P5318/P5318.cpp @@ -6,10 +6,10 @@ struct edge { int u, v; }; -vector e[100001]; +vector e[100001]; vector s; -bool vis_dfs[100001] = {0}, vis_bfs[100001] = {0}; -vector ans_dfs, ans_bfs; +bool vis_dfs[100001] = {0}, vis_bfs[100001] = {0}; +vector ans_dfs, ans_bfs; bool cmp(edge x, edge y) { if (x.v == y.v) { @@ -30,7 +30,7 @@ void dfs(int x) { } void bfs(int x) { - int front, point; + int front, point; queue q; vis_bfs[x] = true; q.push(x); diff --git a/Luogu/P5587/P5587.cpp b/Luogu/P5587/P5587.cpp index a83cd535..4ec76806 100644 --- a/Luogu/P5587/P5587.cpp +++ b/Luogu/P5587/P5587.cpp @@ -11,8 +11,7 @@ int main() { for (long long i = 0; i < tmp.size(); i++) { if (tmp[i] == '<') { if (!s[n].empty()) s[n].pop_back(); - } - else { + } else { s[n].push_back(tmp[i]); } } @@ -22,8 +21,7 @@ int main() { for (long long i = 0; i < tmp.size(); i++) { if (tmp[i] == '<') { if (!r[m].empty()) r[m].pop_back(); - } - else { + } else { r[m].push_back(tmp[i]); } } diff --git a/Luogu/P5657/P5657.cpp b/Luogu/P5657/P5657.cpp index e1393ab5..219d742a 100644 --- a/Luogu/P5657/P5657.cpp +++ b/Luogu/P5657/P5657.cpp @@ -9,8 +9,7 @@ int main() { if ((1ull << n) - 1 < k) { printf("1"); k = (1ull << n) - k + (1ull << n) - 1; - } - else { + } else { printf("0"); } } diff --git a/Luogu/P5682/P5682.cpp b/Luogu/P5682/P5682.cpp index 3885fdfe..512df754 100644 --- a/Luogu/P5682/P5682.cpp +++ b/Luogu/P5682/P5682.cpp @@ -13,8 +13,7 @@ int main() { } if (s.size() <= 1) { cout << -1 << endl; - } - else { + } else { t = 0; for (int i : s) { a[++t] = i; diff --git a/Luogu/P5690/P5690.cpp b/Luogu/P5690/P5690.cpp index 2a30f7a1..cf0c6ce7 100644 --- a/Luogu/P5690/P5690.cpp +++ b/Luogu/P5690/P5690.cpp @@ -8,39 +8,31 @@ int main() { if (1 <= m && m <= 12) { if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) { t = 31; - } - else if (m == 2) { + } else if (m == 2) { t = 28; - } - else { + } else { t = 30; } if (1 <= d && d <= t) { ans = 0; - } - else { + } else { ans = 1; } - } - else if (12 < m && m < 20) { + } else if (12 < m && m < 20) { if (1 <= d && d <= 31) { ans = 1; - } - else { + } else { ans = 2; } - } - else { + } else { if (m % 10 == 1 || m % 10 == 2 || m % 10 == 3 || m % 10 == 5 || m % 10 == 7 || m % 10 == 8) { t = 31; - } - else { + } else { t = 30; } if (1 <= d && d <= t) { ans = 1; - } - else { + } else { ans = 2; } } diff --git a/Luogu/P5707/P5707.cpp b/Luogu/P5707/P5707.cpp index f6d41ce4..af6147f0 100644 --- a/Luogu/P5707/P5707.cpp +++ b/Luogu/P5707/P5707.cpp @@ -6,7 +6,7 @@ int main() { int s, v, m, h; scanf("%d%d", &s, &v); m = s / v; - if(s%v != 0) { + if (s % v != 0) { m++; } m += 10; @@ -14,8 +14,7 @@ int main() { m %= 60; if (h > 7) { printf("%02d", 24 + 7 - h); - } - else { + } else { printf("%02d", 7 - h); } printf(":%02d\n", 60 - m); diff --git a/Luogu/P5731/P5731.cpp b/Luogu/P5731/P5731.cpp index d25bfb4b..54e60a56 100644 --- a/Luogu/P5731/P5731.cpp +++ b/Luogu/P5731/P5731.cpp @@ -1,17 +1,16 @@ // R36471603 -#include +#include using namespace std; int n, k, a[15][15], ax, ay; - int main() { k = ax = 1; scanf("%d", &n); - + /** * ax, ay+1 -> 右侧 * ax, ay-1 -> 左侧 @@ -38,23 +37,23 @@ int main() { * n */ - while(k <= n*n) { - while(ay < n && !a[ax][ay+1]) { // 右侧 不过边界 && 未填数 + while (k <= n * n) { + while (ay < n && !a[ax][ay + 1]) { // 右侧 不过边界 && 未填数 a[ax][++ay] = k++; } - while(ax < n && !a[ax+1][ay]) { // 下方 不过边界 && 未填数 + while (ax < n && !a[ax + 1][ay]) { // 下方 不过边界 && 未填数 a[++ax][ay] = k++; } - while(ay > 1 && !a[ax][ay-1]) { // 左侧 不过边界 && 未填数 + while (ay > 1 && !a[ax][ay - 1]) { // 左侧 不过边界 && 未填数 a[ax][--ay] = k++; } - while(ax > 1 && !a[ax-1][ay]) { // 上方 不过边界 && 未填数 + while (ax > 1 && !a[ax - 1][ay]) { // 上方 不过边界 && 未填数 a[--ax][ay] = k++; } } - for(int i = 1 ; i <= n ; i++) { - for(int j = 1 ; j <= n ; j++) { + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { printf("%3d", a[i][j]); } printf("\n"); diff --git a/Luogu/P5734/P5734.cpp b/Luogu/P5734/P5734.cpp index ccb55a65..ecc18e24 100644 --- a/Luogu/P5734/P5734.cpp +++ b/Luogu/P5734/P5734.cpp @@ -1,6 +1,6 @@ // https://www.luogu.com.cn/record/35887921 -#include +#include using namespace std; @@ -9,7 +9,7 @@ int main() { cin >> n; string s = ""; cin >> s; - for(int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { int act; cin >> act; if (act == 1) { @@ -17,27 +17,23 @@ int main() { cin >> s1; s += s1; cout << s; - } - else if (act == 2) { + } else if (act == 2) { int st, ed; cin >> st >> ed; s = s.substr(st, ed); cout << s; - } - else if (act == 3) { + } else if (act == 3) { int st; string s1; cin >> st >> s1; s.insert(st, s1); cout << s; - } - else if (act == 4) { + } else if (act == 4) { string s1; cin >> s1; - if(s.find(s1) < s.size()) { + if (s.find(s1) < s.size()) { cout << s.find(s1); - } - else { + } else { cout << "-1"; } } diff --git a/Luogu/P5738/P5738.cpp b/Luogu/P5738/P5738.cpp index 14a9123f..a3fca961 100644 --- a/Luogu/P5738/P5738.cpp +++ b/Luogu/P5738/P5738.cpp @@ -5,7 +5,7 @@ using namespace std; struct node { - int score[22]; + int score[22]; double sum, all; node() { @@ -30,7 +30,7 @@ bool cmp(node a, node b) { } int main() { - int n, m; + int n, m; node student[105]; cin >> n >> m; for (int i = 0; i < n; i++) { diff --git a/Luogu/P5739/P5739.cpp b/Luogu/P5739/P5739.cpp index 5c3964e5..2a967998 100644 --- a/Luogu/P5739/P5739.cpp +++ b/Luogu/P5739/P5739.cpp @@ -1,6 +1,6 @@ // R38740581 -#include +#include using namespace std; diff --git a/Luogu/P5740/P5740.cpp b/Luogu/P5740/P5740.cpp index 95b9df85..41a21ee7 100644 --- a/Luogu/P5740/P5740.cpp +++ b/Luogu/P5740/P5740.cpp @@ -6,13 +6,13 @@ using namespace std; struct node { string name; - int chinese; - int math; - int english; - int all; + int chinese; + int math; + int english; + int all; node() { - name = ""; + name = ""; chinese = math = english = all = 0; } @@ -27,7 +27,7 @@ bool cmp(node a, node b) { } int main() { - int n; + int n; node a[1005]; cin >> n; for (int i = 0; i < n; i++) { diff --git a/Luogu/P5741/P5741.cpp b/Luogu/P5741/P5741.cpp index 1c1e9edc..f1929c9e 100644 --- a/Luogu/P5741/P5741.cpp +++ b/Luogu/P5741/P5741.cpp @@ -6,13 +6,13 @@ using namespace std; struct node { string name; - int chinese; - int math; - int english; - int all; + int chinese; + int math; + int english; + int all; node() { - this->name = ""; + this->name = ""; this->chinese = this->math = this->english = this->all = 0; } @@ -27,10 +27,10 @@ bool cmp(node a, node b) { } bool query(node a, node b) { - if(abs(a.chinese - b.chinese) <= 5) { - if(abs(a.math - b.math) <= 5) { - if(abs(a.english - b.english) <= 5) { - if(abs(a.all - b.all) <= 10) { + if (abs(a.chinese - b.chinese) <= 5) { + if (abs(a.math - b.math) <= 5) { + if (abs(a.english - b.english) <= 5) { + if (abs(a.all - b.all) <= 10) { return true; } } @@ -40,20 +40,19 @@ bool query(node a, node b) { } int main() { - int n; + int n; node a[1005]; cin >> n; for (int i = 0; i < n; i++) { a[i].read(); } // sort(a, a + n, cmp); - for(int i = 0 ; i < n ; i++) { - for(int j = i+1 ; j < n ; j++) { - if(query(a[i], a[j])) { - if(a[i].name < a[j].name) { + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (query(a[i], a[j])) { + if (a[i].name < a[j].name) { cout << a[i].name << ' ' << a[j].name << endl; - } - else { + } else { cout << a[j].name << ' ' << a[i].name << endl; } } diff --git a/Luogu/P5742/P5742.cpp b/Luogu/P5742/P5742.cpp index 8c0c492f..3b7f5eed 100644 --- a/Luogu/P5742/P5742.cpp +++ b/Luogu/P5742/P5742.cpp @@ -11,8 +11,7 @@ int main() { cin >> tmp >> x >> s; if (x + s > 140 && x * 0.7 + s * 0.3 >= 80) { cout << "Excellent" << endl; - } - else { + } else { cout << "Not excellent" << endl; } } diff --git a/Luogu/P5743/P5743.cpp b/Luogu/P5743/P5743.cpp index 5df72f0d..d0359235 100644 --- a/Luogu/P5743/P5743.cpp +++ b/Luogu/P5743/P5743.cpp @@ -8,7 +8,7 @@ int main() { int n, sum; sum = 1; cin >> n; - for (int i = n-1; i > 0; i--) { + for (int i = n - 1; i > 0; i--) { sum++; sum *= 2; } diff --git a/Luogu/P5744/P5744.cpp b/Luogu/P5744/P5744.cpp index 978acce2..a1f52a61 100644 --- a/Luogu/P5744/P5744.cpp +++ b/Luogu/P5744/P5744.cpp @@ -5,10 +5,10 @@ using namespace std; int main() { - int n; + int n; string name; - int age; - int score; + int age; + int score; cin >> n; for (int i = 0; i < n; i++) { diff --git a/Luogu/P5908/P5908.cpp b/Luogu/P5908/P5908.cpp index a028b167..225fd629 100644 --- a/Luogu/P5908/P5908.cpp +++ b/Luogu/P5908/P5908.cpp @@ -2,9 +2,9 @@ using namespace std; -int n, a, b, d, ans; +int n, a, b, d, ans; vector g[100005]; -bool vis[100005]; +bool vis[100005]; void dfs(int now, int dis) { vis[now] = true; diff --git a/Luogu/P6382/P6382.cpp b/Luogu/P6382/P6382.cpp index 1f86b2f6..3b432e36 100644 --- a/Luogu/P6382/P6382.cpp +++ b/Luogu/P6382/P6382.cpp @@ -1,17 +1,17 @@ // R39592154 -#include +#include using namespace std; int main() { string name; cin >> name; - if(name[0] != 'M' || name[1] != 'D' || name[2] != 'A') { + if (name[0] != 'M' || name[1] != 'D' || name[2] != 'A') { cout << "1 1 1 1 1" << endl; } else { int i = 7; - while(!('0' <= name[i] && name[i] <= '9')) i--; + while (!('0' <= name[i] && name[i] <= '9')) i--; int last = name[i] - '0'; cout << (last == 1 || last == 9 ? 1 : 0) << ' '; cout << (last == 2 || last == 8 ? 1 : 0) << ' '; diff --git a/Luogu/P6408/P6408.cpp b/Luogu/P6408/P6408.cpp index b1c36c48..f867be4c 100644 --- a/Luogu/P6408/P6408.cpp +++ b/Luogu/P6408/P6408.cpp @@ -1,18 +1,18 @@ -#include +#include using namespace std; int main() { int maxi, maxn, t0, t1; - for(int i = 0 ; i < 5 ; i++) { + for (int i = 0; i < 5; i++) { t1 = 0; - for(int j = 0 ; j < 4 ; j++) { + for (int j = 0; j < 4; j++) { cin >> t0; t1 += t0; } - if(t1 > maxn) { + if (t1 > maxn) { maxn = t1; - maxi = i+1; + maxi = i + 1; } } cout << maxi << ' ' << maxn << endl; diff --git a/Luogu/P6449/P6449.cpp b/Luogu/P6449/P6449.cpp index 118782f9..332d1f29 100644 --- a/Luogu/P6449/P6449.cpp +++ b/Luogu/P6449/P6449.cpp @@ -9,8 +9,7 @@ int main() { int n = 30; if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) { n = 31; - } - else if (i == 2) { + } else if (i == 2) { n = 28; } for (int j = 1; j <= n; j++) { diff --git a/Luogu/P6500/P6500.cpp b/Luogu/P6500/P6500.cpp index fa1e2d0a..b6a5e265 100644 --- a/Luogu/P6500/P6500.cpp +++ b/Luogu/P6500/P6500.cpp @@ -1,19 +1,23 @@ // R39634200 -#include +#include using namespace std; int main() { string a, b, a_max, b_max, a_min, b_min; cin >> a >> b; - for(int i = 0 ; i < a.size() ; i++) { - if(a[i] == '6' || a[i] == '5') a_max += '6', a_min += '5'; - else a_max += a[i], a_min += a[i]; + for (int i = 0; i < a.size(); i++) { + if (a[i] == '6' || a[i] == '5') + a_max += '6', a_min += '5'; + else + a_max += a[i], a_min += a[i]; } - for(int i = 0 ; i < b.size() ; i++) { - if(b[i] == '6' || b[i] == '5') b_max += '6', b_min += '5'; - else b_max += b[i], b_min += b[i]; + for (int i = 0; i < b.size(); i++) { + if (b[i] == '6' || b[i] == '5') + 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; return 0; diff --git a/Luogu/P6832/P6832.cpp b/Luogu/P6832/P6832.cpp index d2d49d12..b4e587ab 100644 --- a/Luogu/P6832/P6832.cpp +++ b/Luogu/P6832/P6832.cpp @@ -6,7 +6,7 @@ using namespace std; int main() { char c; - int a[30] = {0}; + int a[30] = {0}; while (cin >> c) { a[c - 'a']++; } diff --git a/Luogu/P6850/P6850.cpp b/Luogu/P6850/P6850.cpp index c1947092..633aca7f 100644 --- a/Luogu/P6850/P6850.cpp +++ b/Luogu/P6850/P6850.cpp @@ -9,8 +9,7 @@ int main() { 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)) { cout << "AKIOI" << endl; - } - else { + } else { cout << "AFO" << endl; } return 0; diff --git a/Luogu/P7071/P7071.cpp b/Luogu/P7071/P7071.cpp index 86f69380..2fef8f0b 100644 --- a/Luogu/P7071/P7071.cpp +++ b/Luogu/P7071/P7071.cpp @@ -7,8 +7,7 @@ int main() { cin >> n; if (n & 1) { cout << -1 << endl; - } - else { + } else { for (int i = 24; i > 0; i--) { if (n >> i & 1) { cout << (1 << i) << ' '; diff --git a/Luogu/P7072/P7072.cpp b/Luogu/P7072/P7072.cpp index deb997c8..e5ab28cf 100644 --- a/Luogu/P7072/P7072.cpp +++ b/Luogu/P7072/P7072.cpp @@ -3,7 +3,7 @@ using namespace std; int main() { - int n, w, t; + int n, w, t; vector score; cin >> n >> w; for (int i = 1; i <= n; i++) { diff --git a/Luogu/P7074/P7074.cpp b/Luogu/P7074/P7074.cpp index fbb4784f..d616b0ce 100644 --- a/Luogu/P7074/P7074.cpp +++ b/Luogu/P7074/P7074.cpp @@ -2,7 +2,7 @@ using namespace std; -int n, m; +int n, m; long long w[1005][1005], f[1005][1005][2]; long long dfs(int x, int y, int from) { @@ -14,8 +14,7 @@ long long dfs(int x, int y, int from) { } 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]; - } - 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]; } return f[x][y][from]; diff --git a/Luogu/P7079/P7079.cpp b/Luogu/P7079/P7079.cpp index 8cbffb85..05d242e5 100644 --- a/Luogu/P7079/P7079.cpp +++ b/Luogu/P7079/P7079.cpp @@ -3,9 +3,9 @@ using namespace std; int main() { - int n, f[105], ans = 0; + int n, f[105], ans = 0; string s[105]; - char now = 'A'; + char now = 'A'; memset(f, 0x00, sizeof(f)); cin >> n; for (int i = 0; i < n; i++) { diff --git a/Luogu/P7113/P7113.cpp b/Luogu/P7113/P7113.cpp index 3d063694..6a61e9f7 100644 --- a/Luogu/P7113/P7113.cpp +++ b/Luogu/P7113/P7113.cpp @@ -29,8 +29,7 @@ void dfs(int x, __int128 first, __int128 second) { __int128 tmp = gcd(ans[x].first, ans[x].second); ans[x].first /= tmp; ans[x].second /= tmp; - } - else { + } else { first *= ans[x].second; ans[x].first *= second; ans[x].first += first; @@ -39,8 +38,7 @@ void dfs(int x, __int128 first, __int128 second) { ans[x].first /= tmp; ans[x].second /= tmp; } - } - else { + } else { ans[x].first = first; ans[x].second = second; } diff --git a/Luogu/T160508/T160508.cpp b/Luogu/T160508/T160508.cpp index 7cc4901e..ac589ea8 100644 --- a/Luogu/T160508/T160508.cpp +++ b/Luogu/T160508/T160508.cpp @@ -8,18 +8,14 @@ int main() { cin >> score; if (score >= 90) { gpa = 4.0; - } - else if (60 <= score && score <= 89) { + } else if (60 <= score && score <= 89) { gpa = 4.0 - (90 - score) * 0.1; - } - else { + } else { if (floor(sqrt(score) * 10.0) >= 90.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; - } - else { + } else { gpa = 0.0; } } diff --git a/Luogu/UVA673/UVA673.cpp b/Luogu/UVA673/UVA673.cpp index 0bfdb9fb..d7bcb97b 100644 --- a/Luogu/UVA673/UVA673.cpp +++ b/Luogu/UVA673/UVA673.cpp @@ -13,19 +13,16 @@ int main() { for (int i = 0; i < s.size(); i++) { if (s[i] == '(' || 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; goto end; - } - else { + } else { st.pop(); } } if (st.empty()) { cout << "Yes" << endl; - } - else { + } else { cout << "No" << endl; } end:; diff --git a/S2OJ/183/183.cpp b/S2OJ/183/183.cpp index 3fd95100..0ab2a47d 100644 --- a/S2OJ/183/183.cpp +++ b/S2OJ/183/183.cpp @@ -11,11 +11,9 @@ bool check(long long x) { for (i = 1; i < n; i++) { if (a[i] == -1) { t[++top] = x; - } - else if (a[i] > 0) { + } else if (a[i] > 0) { t[++top] = a[i]; - } - else if (top > 1) { + } else if (top > 1) { t[top - 1] += t[top]; top--; } @@ -40,8 +38,7 @@ int main() { mid = l + r + 1 >> 1; if (check(mid)) { l = mid; - } - else { + } else { r = mid - 1; } } diff --git a/S2OJ/438/438.cpp b/S2OJ/438/438.cpp index b203d4dc..b03d2035 100644 --- a/S2OJ/438/438.cpp +++ b/S2OJ/438/438.cpp @@ -22,7 +22,7 @@ int main() { } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { - f[i][j] = i == j ? 0 : 0x3f3f3f3f; + f[i][j] = i == j ? 0 : 0x3f3f3f3f; } } for (int i = 1; i <= n; i++) { @@ -42,7 +42,7 @@ int main() { } } } - if(f[1][n] == 0x3f3f3f3f) { + if (f[1][n] == 0x3f3f3f3f) { cout << "No Solution" << endl; } else { cout << fixed << setprecision(3) << f[1][n] / v << endl;