QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#235741 | #5301. Modulo Ruins the Legend | ushg8877# | WA | 34ms | 3664kb | C++20 | 624b | 2023-11-03 08:10:56 | 2023-11-03 08:10:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MP make_pair
mt19937 rnd(time(0));
int n,m;ll s;
void construct(ll x,ll y,ll p){
int g=__gcd(x,y);
x/=g,y/=g,p/=g;
map<int,int> mp;
for(int i=1;i<=1e6;i++){
ll k=rnd()%m;
mp[k*x%m]=k;
}
while(1){
ll k=rnd()%m;
if(mp.count((p-y*k%m+m)%m)){
cout<<mp[(p-y*k%m+m)%m]<<' '<<k<<endl;
return;
}
}
}
int main(){
ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=1,a;i<=n;i++){
cin>>a;s+=a;
}
ll a=1ll*n*(n+1)/2%m,b=n%m;
ll g=__gcd(a,b);
cout<<s%g<<endl;
construct(a,b,m+s%g-s);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 34ms
memory: 3664kb
input:
6 24 1 1 4 5 1 4
output:
1 21 12
result:
wrong answer Result not equal to solution.