QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#628770 | #5301. Modulo Ruins the Legend | 1025497292 | TL | 1ms | 3708kb | C++17 | 1012b | 2024-10-10 22:10:18 | 2024-10-10 22:10:20 |
Judging History
answer
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define Mirai ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
typedef pair<int,int> pii;
void solve()
{
int n,m;cin>>n>>m;
int sum=0;
for(int i=1;i<=n;i++)
{
int x;cin>>x;
sum+=x;
}
int res=1e18;
int resS,resD=0;
for(int s=0;s<m;s++)
{
for(int d=0;d<m;d++)
{
int now=n*s+n*(n+1)*d/2;
now=(now+sum)%m;
if(now<res)
{
res=now;
resS=s,resD=d;
}
}
}
// cout<<sum<<" "<<n*resS+n*(n+1)*resD/2<<endl;
// cout<<(sum+n*resS+n*(n+1)*resD/2)%m<<endl;
cout<<res<<endl;
cout<<resS<<" "<<resD<<endl;
}
signed main()
{
Mirai;
int T=1;
// freopen("..\\data.in","r",stdin);
// freopen("..\\baoli.out","w",stdout);
// cin>>T;
while(T--)
{
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3708kb
input:
6 24 1 1 4 5 1 4
output:
1 0 5
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
7 29 1 9 1 9 8 1 0
output:
0 0 0
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
1 1 0
output:
0 0 0
result:
ok ok
Test #4:
score: -100
Time Limit Exceeded
input:
1 1000000000 963837005