QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#628692 | #5301. Modulo Ruins the Legend | Sound_Medium | WA | 3ms | 3708kb | C++23 | 902b | 2024-10-10 21:44:41 | 2024-10-10 21:44:42 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, m;
int s,d;
int xx,yy;
int exgcd(int a, int b, int &x, int &y)// 拓欧
{
if (b == 0)
{
x = 1;
y = 0;
return a;
}
int d = exgcd(b, a % b, y, x);
y -= (a / b) * x;
return d;
}
int e;
void solve () {
cin>>n>>m;
int sum=0;
for(int i=1;i<=n;i++){
int x;
cin>>x;
sum+=x;
}
int a=n,b=(n+1)*n/2;
int k=gcd(a,b);
exgcd(a,b,s,d);
s=(s%m+m)%m;
d=(d%m+m)%m;
sum%=m;
int res=exgcd(k,m,xx,yy);
xx=(((-sum)*xx/res)%m+m)%m;
cout<<(((sum)%m+a*s*xx%m+b*d*xx%m)%m)<<endl;
cout<<(s*xx%m)<<" "<<(d*xx%m)<<endl;
}
signed main () {
int T = 1;
std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//cin>>T;
while (T --) solve ();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
input:
6 24 1 1 4 5 1 4
output:
1 15 19
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3652kb
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: 3584kb
input:
1 1 0
output:
0 0 0
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
1 1000000000 963837005
output:
0 0 36162995
result:
ok ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
2 1 0 0
output:
0 0 0
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
2 1000000000 948507269 461613424
output:
0 410120693 589879307
result:
ok ok
Test #7:
score: 0
Accepted
time: 3ms
memory: 3688kb
input:
100000 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
0 0 0
result:
ok ok
Test #8:
score: -100
Wrong Answer
time: 3ms
memory: 3648kb
input:
100000 1000000000 253614966 278270960 980235895 498158918 928430170 216003119 852570558 948400590 239257296 897053667 294741176 38297441 382677590 406314557 609468973 854148232 314532767 738191551 158215002 5865825 920471826 380037058 356271728 749175327 28319049 208101105 953758995 896570758 521930...
output:
520736277 535950000 999989281
result:
wrong answer Result not equal to solution.