QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#876812#5. 在线 O(1) 逆元atgcCompile Error//C++14538b2025-01-31 13:26:162025-01-31 13:26:17

Judging History

This is the latest submission verdict.

  • [2025-01-31 13:26:17]
  • Judged
  • [2025-01-31 13:26:16]
  • Submitted

answer

// #include<bits/stdc++.h>
// using namespace std;
#include"inv.h"
const int maxn = 2e5+10,mod=998244353;
int inv_a[maxn];

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

int inv(int x){
	int64_t scal=1;
	while(x>=maxn)(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((int64_t)z*inv(z)%mod == 1);
	// 	cerr<<z;
	// }
// }

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 ‘void init(int)’:
answer.code:8:53: error: ‘int64_t’ was not declared in this scope
    8 |         inv_a[1]=1;for(int i=2;i<maxn;++i)inv_a[i]=(int64_t)(mod-mod/i)*inv_a[mod%i]%mod;
      |                                                     ^~~~~~~
answer.code:4:1: note: ‘int64_t’ is defined in header ‘<cstdint>’; this is probably fixable by adding ‘#include <cstdint>’
    3 | #include"inv.h"
  +++ |+#include <cstdint>
    4 | const int maxn = 2e5+10,mod=998244353;
answer.code: In function ‘int inv(int)’:
answer.code:12:9: error: ‘int64_t’ was not declared in this scope
   12 |         int64_t scal=1;
      |         ^~~~~~~
answer.code:12:9: note: ‘int64_t’ is defined in header ‘<cstdint>’; this is probably fixable by adding ‘#include <cstdint>’
answer.code:13:24: error: ‘scal’ was not declared in this scope
   13 |         while(x>=maxn)(scal*=-mod/x)%=mod,x=mod%x;
      |                        ^~~~
answer.code:14:16: error: ‘scal’ was not declared in this scope
   14 |         return(scal+mod)*inv_a[x]%mod;
      |                ^~~~