QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#489112#5. 在线 O(1) 逆元qwef_70 1446ms394488kbC++14267b2024-07-24 18:07:432024-07-24 18:07:43

Judging History

This is a historical verdict posted at 2024-07-24 18:07:43.

  • [2024-11-05 22:01:55]
  • 管理员手动重测本题所有提交记录
  • Verdict: 60
  • Time: 4605ms
  • Memory: 394524kb
  • [2024-07-24 18:07:43]
  • Judged
  • Verdict: 70
  • Time: 1446ms
  • Memory: 394488kb
  • [2024-07-24 18:07:43]
  • Submitted

answer

#include "inv.h"
typedef long long ll;
const int N=1e8+114,p=998244353;
int a[N];
void init(int _){
	a[1]=1;
	for(int i=2;i<N;++i) a[i]=(ll)(p-p/i)*a[p%i]%p;
}
int inv(int x){
	for(int i=1,j=x;;++i,j=(j+x>=p?j+x-p:j+x))
		if(j<N)
			return (ll)a[j]*i%p;
}

Details


Pretests


Final Tests

Test #1:

score: 30
Accepted
time: 735ms
memory: 394488kb

Test #2:

score: 40
Accepted
time: 1446ms
memory: 394364kb

Test #3:

score: 0
Time Limit Exceeded