QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#642906#5301. Modulo Ruins the LegendFWKnightshipWA 0ms3560kbC++171.6kb2024-10-15 16:59:512024-10-15 16:59:51

Judging History

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

  • [2024-10-15 16:59:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3560kb
  • [2024-10-15 16:59:51]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using LL = long long;

using vec = array<LL, 2>;

constexpr LL M1 = 1145140019, M2 = 1145140033, pw = 23333;

// a * x % b == gcd(a, b)
void exgcd(LL a, LL b, LL &x, LL &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return;
    }
    exgcd(b, a % b, y, x);
    y -= a / b * x;
}

LL arr[100020];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    LL n, m;
    cin >> n >> m;

    LL n2 = n;

    LL s = 0;

    for (int i = 1; i <= n; ++i)
    {
        cin >> arr[i];
        s += arr[i];
    }

    LL ss, dd;

    if (n % 2)
    {
        LL g = gcd(n, m);

        LL ans = s % g;

        n /= g;
        m /= g;
        s /= g;

        LL x, y;

        exgcd(n, m, x, y);

        // n * x % m == 1

        ss = (x * (m - s) % m + m) % m;

        cout << ans << "\n";

        dd = 0;
    }
    else
    {
        LL nn = n;

        n /= 2;

        LL g = gcd(n, m);

        LL ans = s % g;

        n /= g;
        m /= g;
        s /= g;

        LL x, y;

        exgcd(n, m, x, y);

        ss = x * (m - s);

        cout << ans << "\n";

        if (ss % 2)
        {
            ss = ((ss - (nn + 1)) / 2 % m + m) % m;
            dd = 1;
        }
        else
        {
            ss = (ss / 2 % m + m) % m;
            dd = 0;
        }
    }

    cout << ss << " " << dd;

    LL jxy = 0;

    for (int i = 1; i <= n2; ++i)
    {
        jxy += arr[i] + ss + dd * i;
        jxy %= m;
    }

    cout << '\n' << jxy;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3560kb

input:

6 24
1 1 4 5 1 4

output:

1
6 1
1

result:

wrong output format Extra information in the output file