From 0a74a531415dc5533b808da9fea6d779b0ebfb99 Mon Sep 17 00:00:00 2001 From: Macesuted Date: Thu, 8 Aug 2024 18:34:50 +0800 Subject: [PATCH] =?UTF-8?q?Nowcoder:=202024=E7=89=9B=E5=AE=A2=E6=9A=91?= =?UTF-8?q?=E6=9C=9F=E5=A4=9A=E6=A0=A1=E8=AE=AD=E7=BB=83=E8=90=A58?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Nowcoder/81603D.cpp | 91 +++++++++++++++++++++++++++++++++++++++++++++ Nowcoder/81603E.cpp | 62 ++++++++++++++++++++++++++++++ Nowcoder/81603K.cpp | 42 +++++++++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 Nowcoder/81603D.cpp create mode 100644 Nowcoder/81603E.cpp create mode 100644 Nowcoder/81603K.cpp diff --git a/Nowcoder/81603D.cpp b/Nowcoder/81603D.cpp new file mode 100644 index 0000000..288864f --- /dev/null +++ b/Nowcoder/81603D.cpp @@ -0,0 +1,91 @@ +/** + * @file 81603D.cpp + * @author Macesuted (i@macesuted.moe) + * @date 2024-08-08 + * + * @copyright Copyright (c) 2024 + * + */ + +#include +using namespace std; + +const int base[6][6][6] = { + {}, + {{10, 0, 5, 0, 0, 2}, {0, 9, 0, 4, 0, 2}, {0, 5, 8, 0, 0, 2}, {4, 0, 4, 8, 0, 2}, {2, 0, 0, 0, 9, 4}}, + {{11, 0, 5, 0, 0, 2}, {0, 10, 0, 4, 0, 2}, {0, 5, 9, 0, 0, 2}, {4, 0, 4, 9, 0, 2}, {2, 0, 0, 0, 10, 4}}, + {{12, 0, 5, 0, 0, 2}, {0, 11, 0, 4, 0, 2}, {0, 6, 10, 0, 0, 2}, {4, 0, 4, 10, 0, 2}, {3, 0, 0, 0, 11, 4}}, + {{13, 0, 5, 0, 0, 2}, {0, 12, 0, 4, 0, 2}, {0, 6, 11, 0, 0, 2}, {4, 0, 4, 11, 0, 2}, {3, 0, 0, 0, 12, 4}}, + {{14, 0, 5, 0, 0, 2}, {0, 13, 0, 4, 0, 2}, {0, 7, 12, 0, 0, 2}, {5, 0, 5, 12, 0, 2}, {4, 0, 0, 0, 13, 4}}}; + +int umaVal[20], umaLv[7], card[7][25]; +bool pres[10], frien[10]; + +void solve(void) { + for (int i = 1; i <= 5; i++) cin >> umaVal[i]; + for (int i = 1; i <= 5; i++) cin >> umaVal[10 + i]; + umaVal[6] = 120, umaVal[16] = 0; + for (int i = 1; i <= 6; i++) { + cin >> card[i][21] >> card[i][22] >> card[i][23]; + long double val; + for (int j = 1; j <= 5; j++) cin >> val, umaVal[j] += val; + for (int j = 1; j <= 5; j++) cin >> card[i][j]; + card[i][6] = 0; + } + for (int i = 1; i <= 5; i++) umaVal[i] = min(umaVal[i], 1200); + + int n; + cin >> n; + while (n--) { + for (int i = 1; i <= 6; i++) pres[i] = frien[i] = false; + + int summer, weight, drive, type, nS; + cin >> summer >> weight >> drive >> type >> nS; + long double coef = 0.1 * (drive - 2); + for (int i = 1, x, y; i <= nS; i++) cin >> x >> y, pres[x] = true, frien[x] = y; + int lv = (summer ? 5 : min(5, (umaLv[type]++ / 4 + 1))); + for (int X = 1 + weight; X <= 6; X++) { + long double v[6]; + for (int j = 0; j < 6; j++) v[j] = 0; + + v[0] = base[lv][type][X - 1]; + for (int i = 1; i <= 6; i++) + if (pres[i]) v[0] += card[i][X]; + + v[1] = 1; + for (int i = 1; i <= 6; i++) + if (frien[i]) v[1] *= 1 + 0.01 * card[i][21]; + + v[2] = 1; + for (int i = 1; i <= 6; i++) + if (pres[i]) v[2] += 0.01 * card[i][23]; + + v[3] = 1; + for (int i = 1; i <= 6; i++) + if (pres[i]) v[3] += 0.01 * card[i][22]; + v[3] = 1 + coef * v[3]; + + v[4] = 1 + 0.01 * umaVal[10 + X]; + + v[5] = 1; + for (int i = 1; i <= 6; i++) + if (pres[i]) v[5] += 0.05; + + int val = umaVal[X] + v[0] * v[1] * v[2] * v[3] * v[4] * v[5] + 1e-4; + umaVal[X] = (X == 6 ? val : min(val, 1200)); + } + + for (int i = 1; i <= 6; i++) cout << umaVal[i] << ' '; + cout << endl; + } + return; +} + +int main() { + ios::sync_with_stdio(false), cin.tie(nullptr); + + int _ = 1; + while (_--) solve(); + + return 0; +} \ No newline at end of file diff --git a/Nowcoder/81603E.cpp b/Nowcoder/81603E.cpp new file mode 100644 index 0000000..4b25b41 --- /dev/null +++ b/Nowcoder/81603E.cpp @@ -0,0 +1,62 @@ +/** + * @file 81603E.cpp + * @author Macesuted (i@macesuted.moe) + * @date 2024-08-08 + * + * @copyright Copyright (c) 2024 + * + */ + +#include +using namespace std; + +struct FastMod { + typedef __uint128_t lll; + typedef unsigned long long ull; + ull m, b; + void intt(ull M) { + m = M; + b = (ull)((lll(1) << 64) / M); + } + ull operator()(ull a) { + ull q = (ull)((lll(b) * a) >> 64), r = a - q * m; + return r >= m ? r - m : r; + } +} FST[1000005]; + +int bsum[1000005]; +unordered_set S; +int64_t n; + +int getSum(int64_t v) { return bsum[v / 1000000] + bsum[FST[1000000](v)]; } +void check(int64_t m) { + if (n % m == getSum(m)) S.insert(m); + return; +} + +void solve(void) { + cin >> n; + int64_t nl = max((int64_t)1, n - 108); + int cnt = 0; + for (int64_t m = 1; m * m <= n; m++) { + int64_t nr = n - (m == 1 ? 0 : FST[m](n)); + if (nr < nl) continue; + check(m); + for (int64_t nc = nr; nc >= nl; nc -= m) check(nc / m), cnt++; + } + cout << S.size() << endl; + S.clear(); + return; +} + +int main() { + ios::sync_with_stdio(false), cin.tie(nullptr); + + for (int i = 1; i <= 1000000; i++) bsum[i] = i % 10 + bsum[i / 10], FST[i].intt(i); + + int _; + cin >> _; + while (_--) solve(); + + return 0; +} \ No newline at end of file diff --git a/Nowcoder/81603K.cpp b/Nowcoder/81603K.cpp new file mode 100644 index 0000000..ff4afea --- /dev/null +++ b/Nowcoder/81603K.cpp @@ -0,0 +1,42 @@ +/** + * @file 81603K.cpp + * @author Macesuted (i@macesuted.moe) + * @date 2024-08-08 + * + * @copyright Copyright (c) 2024 + * + */ + +#include +using namespace std; + +#define maxn 500005 + +bool f[maxn]; + +void solve(void) { + string s; + cin >> s; + int n = s.size(); + s = ' ' + s; + for (int i = 0; i <= n; i++) f[i] = false; + f[0] = true; + for (int i = 1; i < n; i++) { + if (!f[i - 1]) continue; + if (i + 2 <= n && s[i] == 'a' && s[i + 1] == 'v' && s[i + 2] == 'a') f[i + 2] = true; + if (i + 4 <= n && s[i] == 'a' && s[i + 1] == 'v' && s[i + 2] == 'a' && s[i + 3] == 'v' && s[i + 4] == 'a') + f[i + 4] = true; + } + cout << (f[n] ? "Yes" : "No") << endl; + return; +} + +int main() { + ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); + + int _; + cin >> _; + while (_--) solve(); + + return 0; +} \ No newline at end of file