QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#640619#5. 在线 O(1) 逆元Yu_mxCompile Error//C++14221b2024-10-14 14:48:252024-11-05 22:05:20

Judging History

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

  • [2024-11-05 22:05:20]
  • 管理员手动重测本题所有提交记录
  • [2024-10-14 14:48:27]
  • 评测
  • [2024-10-14 14:48:25]
  • 提交

answer

#include"inv.h"

int mod;

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

int inv(int x){
	int p = mod;
	int k = p-2;
	int res = 1%p;
	while(k){
		if(k&1) res = 1LL*res*a%p;
		k >>= 1;
		a = 1LL*a*a%p;
	}
	return res;
}

Details

implementer.cpp: In function ‘int main()’:
implementer.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
answer.code: In function ‘int inv(int)’:
answer.code:14:39: error: ‘a’ was not declared in this scope
   14 |                 if(k&1) res = 1LL*res*a%p;
      |                                       ^
answer.code:16:17: error: ‘a’ was not declared in this scope
   16 |                 a = 1LL*a*a%p;
      |                 ^