牛客多校加赛E
Everyone is bot
题目链接
题目大意
\(n\)个人进行fudu游戏,每一轮若第\(i\)个人是第\(j\)个fudu的人,他能获得\(a[i,j]\)个奖励,若某人是倒数第\(p\)个fudu的人,他将获得\(-154\)的奖励,若无人fudu,则游戏结束,问在每个人采取最优策略下每个人获得的奖励数量
题解
我们可以确定的是,\(n\)个人中一定没人选择第\(n-p\)个进行fudu,这样就一定没有第\(n-2*p\)个fudu的人,以此类推,第\(n-k*p\)个都不会有人fudu,因此fudu游戏一定在\(n%p\)的位置结束
代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 | #include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 998244353, N = 1e5 + 6;
const int M = 5e3 + 5;
int a[M][M];
int n;
int q;
void solve() {
cin >> n >> q;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> a[i][j];
}
}
for (int i = 1; i <= n; i++) {
if (i <= n % q) {
cout << a[i][i] << ' ';
}
else {
cout << 0 << ' ';
}
}
cout << endl;
}
signed main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int _;
_ = 1;
//cin >> _;
while (_--) {
solve();
}
return 0;
}
|