QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#658011 | #5301. Modulo Ruins the Legend | sunjq | WA | 867ms | 3724kb | C++20 | 1.3kb | 2024-10-19 15:58:24 | 2024-10-19 15:58:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
#define pi pair<int, int>
#define yyy cout<<"Yes\n"
#define nnn cout<<"No\n"
#define int128 __int128_t
const int N = 2e6 + 5;
int m, n;
void solve()
{
cin >> n >> m;
int sum = 0;
int Nn = n;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
sum += x;
}
sum %= m;
int ans = m, k = 0;
m *= 2;
int res = m - 2 * sum;
if(Nn % 2 == 1) {
for (int i = 0; i < 600000000 ; i += 2) {
int t = (n * i % (m) - (res));
if(t >= 0 && t % 2 == 0) {
if(ans > t / 2) {
ans = t / 2;
k = i;
}
}
}
}
else {
for (int i = (Nn + 1); i < 600000000 ; i += 2) {
int t = (n * i % (m) - (res));
if(t % 2 == 0 && t >= 0) {
if(ans > t / 2) {
ans = t / 2;
k = i;
}
}
}
}
cout << (ans == m / 2 ? 0 : ans) << '\n';
cout << k % (Nn + 1) / 2 << " " << k / (Nn + 1);
}
signed main()
{
ios;
int t = 1;
//cin >> t;
while (t--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 857ms
memory: 3668kb
input:
6 24 1 1 4 5 1 4
output:
1 2 1
result:
ok ok
Test #2:
score: 0
Accepted
time: 857ms
memory: 3652kb
input:
7 29 1 9 1 9 8 1 0
output:
0 0 0
result:
ok ok
Test #3:
score: 0
Accepted
time: 861ms
memory: 3640kb
input:
1 1 0
output:
0 0 0
result:
ok ok
Test #4:
score: 0
Accepted
time: 861ms
memory: 3668kb
input:
1 1000000000 963837005
output:
0 0 36162995
result:
ok ok
Test #5:
score: 0
Accepted
time: 857ms
memory: 3724kb
input:
2 1 0 0
output:
0 0 0
result:
ok ok
Test #6:
score: 0
Accepted
time: 857ms
memory: 3720kb
input:
2 1000000000 948507269 461613424
output:
0 1 196626435
result:
ok ok
Test #7:
score: 0
Accepted
time: 863ms
memory: 3592kb
input:
100000 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
0 0 0
result:
ok ok
Test #8:
score: 0
Accepted
time: 867ms
memory: 3592kb
input:
100000 1000000000 253614966 278270960 980235895 498158918 928430170 216003119 852570558 948400590 239257296 897053667 294741176 38297441 382677590 406314557 609468973 854148232 314532767 738191551 158215002 5865825 920471826 380037058 356271728 749175327 28319049 208101105 953758995 896570758 521930...
output:
46613 4640 1
result:
ok ok
Test #9:
score: -100
Wrong Answer
time: 863ms
memory: 3656kb
input:
100000 998244353 561002596 498658036 721339539 63377827 532179242 934651519 234198881 490149304 2056307 499913682 427679408 694677560 516580968 300129454 816286800 688594301 183049581 456627420 495848352 273497462 953217060 796225499 207179832 728054671 409492082 25003432 810431468 206421553 5569626...
output:
1 34383 2006
result:
wrong answer Result not equal to solution.