QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#657151 | #5301. Modulo Ruins the Legend | ShiyuKirara | WA | 574ms | 3628kb | C++20 | 3.3kb | 2024-10-19 14:16:04 | 2024-10-19 14:16:05 |
Judging History
answer
#include <bits/stdc++.h>
#define inf 1e18
using namespace std;
using ll = long long;
#define int long long
#define PII pair<int, int>
#define all(a) a.begin() + 1, a.begin() + 1 + n
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const ll N = 2e5 + 10, mod = 998244353, INF = 1e9 + 10;
void solve()
{
int n, m;
cin >> n >> m;
vector<ll> a(n + 10);
int sum = 0;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
sum += a[i];
}
int mn = sum % m;
int aa = 0, bb = 0;
int dd = n * (n + 1) / 2;
for (int i = 0; i <= 10000; i++)
{
for (int j = 0; j <= 10000; j++)
{
if ((sum + n * i) % m < mn)
mn = (sum + n * i) % m, aa = i, bb = 0;
if ((sum + dd * j) % m < mn)
mn = (sum + dd * j) % m, aa = 0, bb = j;
if((sum+n*i+dd*j)%m<mn)
mn=(sum+n*i+dd*j)%m,aa=i,bb=j;
}
}
cout << mn << endl << aa << " " << bb;
}
signed main()
{
ios;
int T = 1;
// cin>>T;
while (T--)
{
solve();
}
return 0;
}
// Shift+Alt+F格式化
// ⠀⠀⠀⢛⢆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠤⠀⠀⠂⣠⡀⢀⣀⠀⠠⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⡄⠀⠀⠀
// ⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⢀⢤⢤⡘⠀⠀⠀⠀⠔⠋⠘⢆⠀⠙⢦⠀⠑⠢⡀⠀⠀⠀⠀⠀⠀⠀⠀⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠣⠀⠀⠀⠀⠠⢢⠃⠀⠈⠀⠀⠀⠀⠀⠀⠉⢿⣷⡀⠀⠑⡄⠀⠈⢢⠀⠀⢀⡀⠀⢰⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⠰⠡⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢻⣧⠀⠀⠙⠀⠀⠀⣇⠀⠀⠀⠀⠚⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠰⣇⠀⠰⠁⠀⠀⠀⠀⣴⠀⠀⠀⠀⠰⢧⠀⠀⠘⣿⡄⠀⠀⠀⠀⠰⡌⣱⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠤⠀⠀⠉⠀⡁⠀⠀⢠⠀⠀⢎⡆⠀⠀⠀⠐⡤⠵⢖⢲⣿⣇⠀⠀⠰⣦⣦⡈⢫⣃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⢠⡀⠀⠀⢀⡅⣤⠀⣼⠒⠞⣀⡣⣤⣤⣤⣴⢷⣤⣤⠷⣮⢿⠀⠀⠀⠀⠈⠹⡰⠳⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠃⣿⣀⣿⡾⢷⡖⢶⡄⠉⠁⠈⠀⢏⠁⠉⠹⢘⠀⠀⠀⠀⠀⠀⣼⠷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡏⣿⡄⠘⠧⡁⠀⠇⠀⠀⠀⠀⠈⠀⠀⠀⠈⠀⠀⣾⣦⣶⣤⣿⣦⠲⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣠⢁⢹⣇⠀⠀⠀⠀ ~~~ ⠈⣠⠀⠀⣿⣿⣿⣿⡿⣿⣧⡘⢄⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⣾⢸⣿⣦⣀⠂⠀⠀⠀⠀⠀⠀⠀⠀⠔⠊⢹⠀⠀⡹⠛⠟⠁⠠⣇⠛⠿⢦⡑⢄⠀⠀⠄⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⢠⣈⣸⡟⠁⠈⡹⠛⠉⠉⠉⢒⡀⢔⠁⠀⠀⢸⣿⣿⣷⠀⠀⢀⡠⡚⢦⣒⣄⠈⠀⠑⠤⡀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠐⠁⢀⡠⢺⣿⣿⡟⠀⠀⠈⠢⠇⠀⡀⢺⡶⣾⣕⣄⡀⣼⣿⣿⡿⠀⠉⠁⠀⠘⡄⠱⢿⣿⣄⡀⠑⠌⠢⡀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⢀⠴⣋⢠⣾⣿⣿⡁⠀⠀⠀⠀⠀⡸⢁⣿⠇⣿⢻⣷⡍⢾⣿⣿⣿⡄⠀⠀⠀⠀⣸⢧⠈⢻⣿⣿⣦⣀⣀⢠⠀⠀⠀⠀
详细
Test #1:
score: 100
Accepted
time: 574ms
memory: 3564kb
input:
6 24 1 1 4 5 1 4
output:
1 0 5
result:
ok ok
Test #2:
score: 0
Accepted
time: 574ms
memory: 3628kb
input:
7 29 1 9 1 9 8 1 0
output:
0 0 0
result:
ok ok
Test #3:
score: 0
Accepted
time: 574ms
memory: 3604kb
input:
1 1 0
output:
0 0 0
result:
ok ok
Test #4:
score: -100
Wrong Answer
time: 574ms
memory: 3624kb
input:
1 1000000000 963837005
output:
963837005 0 0
result:
wrong answer Participant answer greater than judge