QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#139513#5301. Modulo Ruins the LegendRiladavinWA 1ms3524kbC++142.3kb2023-08-13 19:37:362023-08-13 19:37:40

Judging History

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

  • [2023-08-13 19:37:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3524kb
  • [2023-08-13 19:37:36]
  • 提交

answer

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <climits>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define sz(s) int64_t(s.size())
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())

const ll mod = 1e9 + 7;

template<class T>
istream &operator>>(istream &in, vector <T> &v) {
    for (auto &x: v) { in >> x; }
    return in;
}

template<class T>
ostream &operator<<(ostream &out, vector <T> &v) {
    for (auto &x: v) { out << x << " "; }
    return out;
}

template<class T, class U>
istream &operator>>(istream &in, pair<T, U> &v) {
    in >> v.X >> v.Y;
    return in;
}

template<class T, class U>
ostream &operator<<(ostream &out, pair<T, U> &v) {
    out << v.X << " " << v.Y;
    return out;
}

template<class T, class U>
void chkmax(T &a, U b) {
    a = max(a, (T) b);
}

template<class T, class U>
void chkmin(T &a, U b) {
    a = min(a, (T) b);
}

ll ppow(ll x, ll s) {
    ll res = 1;
    while (s) {
        if (s % 2) {
            (res *= x) %= mod;
        }
        (x *= x) %= mod;
        s /= 2;
    }
    return res;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    cin >> a;
    ll sum = accumulate(all(a), 0ll) % m;
    pair<int,int> ans = {-1, -1};
    ll ans_val = 1e18;
    const ll BUBEN = 500;
    ll add = n * (n + 1) / 2;
    add %= m;
    for (ll s = 0;s <= min(n, m - 1);s++) {
        for (ll d = 0; d < min(BUBEN, m); d++) {
            ll cur = sum + add * d % m + n * s % m;
            cur %= m;
            if (cur < ans_val) {
                ans_val = cur;
                ans = {s, d};
            }
        }
    }

    cout << ans_val << endl << ans;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3448kb

input:

6 24
1 1 4 5 1 4

output:

1
0 5

result:

ok ok

Test #2:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

7 29
1 9 1 9 8 1 0

output:

0
0 0

result:

ok ok

Test #3:

score: 0
Accepted
time: 1ms
memory: 3520kb

input:

1 1
0

output:

0
0 0

result:

ok ok

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3452kb

input:

1 1000000000
963837005

output:

963837005
0 0

result:

wrong answer Participant answer greater than judge