QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#684481#5301. Modulo Ruins the LegendtravelWA 0ms3628kbC++141.1kb2024-10-28 13:50:522024-10-28 13:50:53

Judging History

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

  • [2024-10-28 13:50:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-10-28 13:50:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> PII;
#define endl "\n"
#define ft first
#define sd second
#define pb push_back
const int MOD = 1e9 + 7;
int a, b, s, d, n, m, sum;
int exgcd(int ta, int tb, int &x, int &y)
{
    if (!tb)
    {
        x = 1;
        y = 0;
        return ta;
    }
    int d = exgcd(tb, ta % tb, y, x);
    y -= (ta / tb) * x;
    return d;
}
void solve()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        sum += x;
    }
    a = n, b = (n + 1) * n / 2;
    int g1 = __gcd(a, b);
    int g2 = __gcd(g1, m);
    int ans = sum % g2;
    int w = ans - sum;
    int x,y;
    int k1 = w / g1;
    int d = exgcd(a,b,x,y);
    x *=k1,y *=k1;
    x = ((x + m) % m + m) % m;
    y = ((y + m) % m + m) % m;
    cout<<ans<<endl;
    // cout<<(sum + a * x + b * y) % m<<endl;
    cout<<x<<' '<<y<<endl;
    return;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    while (T--)
        solve();
    return 0;
}
/*
6 24
1 1 4 5 1 4
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3628kb

input:

6 24
1 1 4 5 1 4

output:

1
15 19

result:

ok ok

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3628kb

input:

7 29
1 9 1 9 8 1 0

output:

0
25 0

result:

wrong answer Result not equal to solution.