QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#628770#5301. Modulo Ruins the Legend1025497292TL 1ms3708kbC++171012b2024-10-10 22:10:182024-10-10 22:10:20

Judging History

你现在查看的是最新测评结果

  • [2024-10-10 22:10:20]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3708kb
  • [2024-10-10 22:10:18]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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

output:


result: