QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#567279#5. 在线 O(1) 逆元hly0 0ms3876kbC++14293b2024-09-16 10:46:112024-11-05 22:03:55

Judging History

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

  • [2024-11-05 22:03:55]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:0ms
  • 内存:3876kb
  • [2024-09-16 10:46:11]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3884kb
  • [2024-09-16 10:46:11]
  • 提交

answer

int prime; 
void init(int p)
{
	prime=p;
}

int inv(int x)
{
	int s1=1,s2=0;
	int t1=0,t2=1;
	int a=x,b=prime;
	int q;
	while(b!=0)
	{
		q=a/b;
		int c=a;
		a=b;
		b=c-a*q;
		int s3=s2;
		s2=-1*q*s3+s1;
		s1=s3;
		int t3=t2;
		t2=-1*q*t3+t1;
		t1=t3;
	}
	return s2;
}

Details


Pretests


Final Tests

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3876kb

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 3688kb

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 3608kb

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 3840kb

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 3828kb