QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#235751#5301. Modulo Ruins the Legendushg8877#WA 667ms66352kbC++20738b2023-11-03 08:23:572023-11-03 08:23:57

Judging History

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

  • [2023-11-03 08:23:57]
  • 评测
  • 测评结果:WA
  • 用时:667ms
  • 内存:66352kb
  • [2023-11-03 08:23:57]
  • 提交

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;
ll gcd(ll a,ll b){
	if(a+b==0) return m;
	else if(!a||!b) return a?a:b;
	return gcd(b,a%b); 
} 
void construct(ll x,ll y,ll p){
	ll g=gcd(x,y);
	x/=g,y/=g,p/=g;
	map<ll,ll> 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;s%=m;
	ll g=gcd(gcd(a,b),(ll)m);
	cout<<s%g<<endl;
	construct(b,a,(m+s%g-s)%m);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 30ms
memory: 3668kb

input:

6 24
1 1 4 5 1 4

output:

1
1 7

result:

ok ok

Test #2:

score: 0
Accepted
time: 36ms
memory: 3676kb

input:

7 29
1 9 1 9 8 1 0

output:

0
16 25

result:

ok ok

Test #3:

score: 0
Accepted
time: 6ms
memory: 3676kb

input:

1 1
0

output:

0
0 0

result:

ok ok

Test #4:

score: 0
Accepted
time: 618ms
memory: 66348kb

input:

1 1000000000
963837005

output:

0
557663829 478499166

result:

ok ok

Test #5:

score: 0
Accepted
time: 6ms
memory: 3660kb

input:

2 1
0 0

output:

0
0 0

result:

ok ok

Test #6:

score: 0
Accepted
time: 651ms
memory: 66052kb

input:

2 1000000000
948507269 461613424

output:

0
849356361 963722195

result:

ok ok

Test #7:

score: 0
Accepted
time: 10ms
memory: 3728kb

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: 667ms
memory: 66256kb

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
846175192 307658897

result:

ok ok

Test #9:

score: -100
Wrong Answer
time: 564ms
memory: 66352kb

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
310616151 414176019

result:

wrong answer Result not equal to solution.