QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#657976#5301. Modulo Ruins the LegendsunjqWA 719ms3664kbC++201.7kb2024-10-19 15:54:272024-10-19 15:54:31

Judging History

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

  • [2024-10-19 15:54:31]
  • 评测
  • 测评结果:WA
  • 用时:719ms
  • 内存:3664kb
  • [2024-10-19 15:54:27]
  • 提交

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;
    if(Nn % 2 == 1) {
        int flag = -1, s = 0;
        for (int i = 0; i < 500000000 ; i += 2) {
            int t = (n * i % (2 * m) - (2 * m - 2 * sum));
            if(t >= 0 && t % 2 == 0) {
                if(flag == -1) {
                    flag = t;
                }
                if(ans > t / 2) {
                    ans = t / 2;
                    k = i;
                }
                s++;
                if(s > 1 && t == flag) break;
            }
            
        }
    }
    else {
        int flag = -1, s = 0;
        for (int i = (Nn + 1); i < 500000000 ; i += 2) {
            int t = (n * i % (2 * m) - (2 * m - 2 * sum));
            if(t % 2 == 0 && t >= 0) {
                if(flag == -1) flag = t;
                if(ans > t / 2) {
                    ans = t / 2;
                    k = i;
                }
                s++;
                if(s > 1 && flag == t) break;
            }
            
        }
    }
    cout << (ans == m ? 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: 1ms
memory: 3660kb

input:

6 24
1 1 4 5 1 4

output:

1
2 1

result:

ok ok

Test #2:

score: 0
Accepted
time: 718ms
memory: 3596kb

input:

7 29
1 9 1 9 8 1 0

output:

0
0 0

result:

ok ok

Test #3:

score: 0
Accepted
time: 718ms
memory: 3652kb

input:

1 1
0

output:

0
0 0

result:

ok ok

Test #4:

score: 0
Accepted
time: 719ms
memory: 3596kb

input:

1 1000000000
963837005

output:

0
0 36162995

result:

ok ok

Test #5:

score: 0
Accepted
time: 718ms
memory: 3664kb

input:

2 1
0 0

output:

0
0 0

result:

ok ok

Test #6:

score: -100
Wrong Answer
time: 718ms
memory: 3600kb

input:

2 1000000000
948507269 461613424

output:

0
0 0

result:

wrong answer Result not equal to solution.