QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#697040 | #5301. Modulo Ruins the Legend | Godwang | WA | 7ms | 3712kb | C++23 | 1.3kb | 2024-11-01 09:57:39 | 2024-11-01 09:57:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define endl '\n'
#define ll long long
ll extend_gcd(ll a,ll b,ll &x,ll &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
ll d=extend_gcd(b,a%b,y,x);
y-=a/b*x;
return d;
}
const int N=1e5+10;
int tt;
ll n;
ll m;
ll sum;
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//freopen("ain.txt","r",stdin);freopen("aout.txt","w",stdout);
ll gcdab=0,gcdabm=0;
cin>>n>>m;
rep(i,1,n)
{
ll temp;
cin>>temp;
sum+=temp;
}
ll a=n,b=(n+1)*n/2;
gcdab=__gcd(a,b);
gcdabm=__gcd(m,__gcd( n,(1+n)*n/2 ));
ll ans=sum%gcdabm;
cout<<sum%gcdabm<<endl;
if(sum==ans)
{
cout<<"0 0";
exit(0);
}
ll k1,t;
extend_gcd(gcdab,m,k1,t);
//
// cout<<k1<<" "<<t<<endl;
// exit(0);
//
ll k2=(ans-sum)/gcdabm;
k2%=m;
//
k1=k1*k2;
//cout<<k1<<endl<<endl;
k1%=m;
//
//cout<<k1<<" "<<k2<<endl<<endl;
ll s,d;
extend_gcd(a,b,s,d);
//
// cout<<s<<" "<<d<<endl;
s*=k1;
d*=k1;
s+=m;
s%=m;
d+=m;
d%=m;
cout<<s<<" "<<d;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3688kb
input:
6 24 1 1 4 5 1 4
output:
1 15 19
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3712kb
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: 3704kb
input:
1 1 0
output:
0 0 0
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
1 1000000000 963837005
output:
0 0 36162995
result:
ok ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
2 1 0 0
output:
0 0 0
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
2 1000000000 948507269 461613424
output:
0 410120693 589879307
result:
ok ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3652kb
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: 0
Accepted
time: 6ms
memory: 3584kb
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:
46613 535950000 999089281
result:
ok ok
Test #9:
score: 0
Accepted
time: 7ms
memory: 3588kb
input:
100000 998244353 561002596 498658036 721339539 63377827 532179242 934651519 234198881 490149304 2056307 499913682 427679408 694677560 516580968 300129454 816286800 688594301 183049581 456627420 495848352 273497462 953217060 796225499 207179832 728054671 409492082 25003432 810431468 206421553 5569626...
output:
0 813586357 839886562
result:
ok ok
Test #10:
score: -100
Wrong Answer
time: 6ms
memory: 3600kb
input:
100000 823593588 49428507 531539751 61870891 800048628 775048962 784733848 328557377 689322372 219461104 675220341 766029393 488914111 239397724 96030886 535128775 725148224 781428428 415057434 63184780 813491758 45833062 206477264 794055396 620712453 773776688 121478140 274571586 180906090 39075043...
output:
0 -517977248 729780166
result:
wrong answer Integer parameter [name=s] equals to -517977248, violates the range [0, 823593587]