QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#876818#5. 在线 O(1) 逆元atgc10 35ms12072kbC++14559b2025-01-31 13:31:372025-01-31 13:31:39

Judging History

This is the latest submission verdict.

  • [2025-01-31 13:31:39]
  • Judged
  • Verdict: 10
  • Time: 35ms
  • Memory: 12072kb
  • [2025-01-31 13:31:37]
  • Submitted

answer

// #include<bits/stdc++.h>
// using namespace std;
#include"inv.h"
const int maxn = 1<<21|17,mod=998244353;
int inv_a[maxn];

void init(int){
	inv_a[1]=1;for(int i=2;i<maxn;++i)inv_a[i]=(long)(mod-mod/i)*inv_a[mod%i]%mod;
}

int inv(int x){
	long scal=1;
	while(x>=maxn)(scal*=-mod/x)%=mod,x=mod%x,(scal*=-mod/x)%=mod,x=mod%x;
	return(scal+mod)*inv_a[x]%mod;
}

// signed main() {
// 	ios::sync_with_stdio(0),cin.tie(0);
	// init(0);
	// while(1){
	// 	int z=rand()%mod+1;
	// 	assert((long)z*inv(z)%mod == 1);
	// 	cerr<<z;
	// }
// }

Details


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 14ms
memory: 12072kb

Test #2:

score: 0
Wrong Answer
time: 35ms
memory: 12000kb

Test #3:

score: 0
Wrong Answer
time: 35ms
memory: 11956kb

Test #4:

score: 0
Wrong Answer
time: 34ms
memory: 12048kb

Test #5:

score: 0
Wrong Answer
time: 33ms
memory: 12056kb