Skip to content

Commit

Permalink
Nowcoder: 2024牛客暑期多校训练营8
Browse files Browse the repository at this point in the history
  • Loading branch information
Macesuted committed Aug 8, 2024
1 parent 76dd2bd commit 0a74a53
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 0 deletions.
91 changes: 91 additions & 0 deletions Nowcoder/81603D.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* @file 81603D.cpp
* @author Macesuted ([email protected])
* @date 2024-08-08
*
* @copyright Copyright (c) 2024
*
*/

#include <bits/stdc++.h>
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;
}
62 changes: 62 additions & 0 deletions Nowcoder/81603E.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* @file 81603E.cpp
* @author Macesuted ([email protected])
* @date 2024-08-08
*
* @copyright Copyright (c) 2024
*
*/

#include <bits/stdc++.h>
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<int64_t> 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;
}
42 changes: 42 additions & 0 deletions Nowcoder/81603K.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @file 81603K.cpp
* @author Macesuted ([email protected])
* @date 2024-08-08
*
* @copyright Copyright (c) 2024
*
*/

#include <bits/stdc++.h>
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;
}

0 comments on commit 0a74a53

Please sign in to comment.