QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#657758 | #5301. Modulo Ruins the Legend | yillin | WA | 6ms | 3716kb | C++20 | 2.0kb | 2024-10-19 15:24:36 | 2024-10-19 15:24:37 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define PII pair<int,int>
#define ull unsigned long long
//#define lson (o << 1)
//#define rson (o << 1 | 1)
#define mt ((l+r)/2)
#define lowbit(x) x & -x
#define endl '\n'
using namespace std;
using ll = long long;
inline int read(){int k=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}//getchar_unlocked()
while(c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return k*f;}
template<typename T>T qpow(T a, ll n){T ans = 1; while (n){if (n & 1)ans = ans * a; n >>= 1;a = a * a;}return ans;}
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;}
template<typename T> inline void print(T x) { if (x > 9) print(x / 10); putchar(x % 10 + '0'); }
template<typename T> inline void Pr(T x, char c = '\n') { if (x < 0) putchar('-'), x = -x; print(x); putchar(c); }
inline void write(int x){if(x<0)putchar('-'),x=-x;if (x > 9) write(x / 10);putchar(x % 10 + '0');}
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f3f3f3f3f;
//const int p = 1e9 + 7;
const int N=3e5+10;
//int a[maxn],b[maxn];
//int a[N],b[N];
//const int N = 2e5 + 10;
//string s[705];
int a[N],b[N];
void solve()
{
int n,m;
cin>>n>>m;
int sum=0;
for(int i=1;i<=n;i++)
{
int num;
cin>>num;
sum+=num;
}
sum%=m;
if(sum==0)
{
cout<<0<<endl;
cout<<0<<' '<<0<<endl;
return;
}
int a=n*(n+1)/2;
int b=n;
int x,y;//x--d,y--s
exgcd(a,b,x,y);
int qq=__gcd(a,b);
x=(x+m)%m;y=(y+m)%m;
for(int i=0;i<m;i++)
{
int tmp=i+m-sum;
if(tmp%qq==0)
{
//cout<<"tmp:"<<tmp<<endl;
int s=tmp/qq;
cout<<i<<endl;
//cout<<y*s<<' '<<x*s<<endl;
//cout<<y<<' '<<x<<endl;
cout<<(y*s+m)%m<<' '<<(x*s+m)%m<<endl;
return;
}
}
//
}
signed main()
{
cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
int _;
_=1;
//cin >> _;
while(_--)solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
input:
6 24 1 1 4 5 1 4
output:
1 15 3
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3600kb
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: 3652kb
input:
1 1 0
output:
0 0 0
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
1 1000000000 963837005
output:
0 36162995 0
result:
ok ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
2 1 0 0
output:
0 0 0
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
2 1000000000 948507269 461613424
output:
0 410120693 589879307
result:
ok ok
Test #7:
score: 0
Accepted
time: 3ms
memory: 3600kb
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: 3600kb
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 9281
result:
ok ok
Test #9:
score: -100
Wrong Answer
time: 6ms
memory: 3660kb
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:
42004 813544353 3694
result:
wrong answer Participant answer greater than judge