QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#16076#5. 在线 O(1) 逆元PreanCompile Error//C++1.0kb2021-11-17 18:24:052024-11-05 21:46:13

Judging History

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

  • [2024-11-05 21:46:13]
  • 管理员手动重测本题所有提交记录
  • [2024-11-05 21:42:49]
  • 管理员手动重测本题所有提交记录
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-18 04:02:43]
  • 评测
  • [2021-11-17 18:24:05]
  • 提交

answer

#include "inv.h"
typedef unsigned ui;
typedef unsigned long long ull;
const ui mod=1e9+7,M1=1000,M2=M1*M1;
const double invM1=1./M1+1e-15,INV=1.*M2/mod+1e-15;
ui T,len,fra[M2+5],inv[M2+5],sum[M2+5];
ui q[M2+5];ull p[M2+5];
inline ull abs(const ull&a){
	return a>>63?-a:a;
}
inline void Init(){
	ui i,j,x;
	for(i=1;i^M1;++i){
		const double&INV=1./i+1e-15;
		for(j=0;j^i;++j)if(!sum[x=1ull*j*M2*INV])sum[x]=1,fra[x]=M1*i+j;
	}
	for(i=0;i<=M2;++i){
		if(sum[i])++len,q[len]=fra[i]*invM1,p[len]=1ull*(fra[i]-q[len]*M1)*mod;
		if(i)sum[i]+=sum[i-1];inv[i]=i>1?1ull*(mod-mod/i)*inv[mod%i]%mod:i;
	}
}
inline ui Inv(const ui&a){
	static ui q,k;static ull t;
	if(a<=M2)return inv[a];if(mod-a<=M2)return mod-inv[mod-a];k=sum[ui(a*INV)];
	if(k<=len){
		q=::q[k];t=1ull*a*q-p[k];
		if(abs(t)<=M2)return 1ull*q*(t>>63?mod-inv[-t]:inv[t])%mod;
	}
	if(++k<=len){
		q=::q[k];t=1ull*a*q-p[k];
		if(abs(t)<=M2)return 1ull*q*(t>>63?mod-inv[-t]:inv[t])%mod;
	}
	return-1;
}
void init(int p){
	Init();
}
int query(int x){
	return Inv(x);
}

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:6:28: error: ‘ui inv [1000005]’ redeclared as different kind of entity
    6 | ui T,len,fra[M2+5],inv[M2+5],sum[M2+5];
      |                            ^
In file included from answer.code:1:
inv.h:2:5: note: previous declaration ‘int inv(int)’
    2 | int inv(int n);
      |     ^~~
answer.code: In function ‘void Init()’:
answer.code:19:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   19 |                 if(i)sum[i]+=sum[i-1];inv[i]=i>1?1ull*(mod-mod/i)*inv[mod%i]%mod:i;
      |                                            ^
answer.code:19:76: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   19 |                 if(i)sum[i]+=sum[i-1];inv[i]=i>1?1ull*(mod-mod/i)*inv[mod%i]%mod:i;
      |                                                                            ^
answer.code:19:66: error: invalid operands of types ‘long long unsigned int’ and ‘int(int)’ to binary ‘operator*’
   19 |                 if(i)sum[i]+=sum[i-1];inv[i]=i>1?1ull*(mod-mod/i)*inv[mod%i]%mod:i;
      |                                                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~
      |                                                      |                     |
      |                                                      |                     int(int)
      |                                                      long long unsigned int
answer.code: In function ‘ui Inv(const ui&)’:
answer.code:24:30: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   24 |         if(a<=M2)return inv[a];if(mod-a<=M2)return mod-inv[mod-a];k=sum[ui(a*INV)];
      |                              ^
answer.code:24:30: error: invalid conversion from ‘int (*)(int)’ to ‘ui’ {aka ‘unsigned int’} [-fpermissive]
   24 |         if(a<=M2)return inv[a];if(mod-a<=M2)return mod-inv[mod-a];k=sum[ui(a*INV)];
      |                              ^
      |                              |
      |                              int (*)(int)
answer.code:24:65: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   24 |         if(a<=M2)return inv[a];if(mod-a<=M2)return mod-inv[mod-a];k=sum[ui(a*INV)];
      |                                                                 ^
answer.code:24:55: error: invalid operands of types ‘const ui’ {aka ‘const unsigned int’} and ‘int(int)’ to binary ‘operator-’
   24 |         if(a<=M2)return inv[a];if(mod-a<=M2)return mod-inv[mod-a];k=sum[ui(a*INV)];
      |                                                    ~~~^~~~~~~~~~~
      |                                                    |            |
      |                                                    |            int(int)
      |                                                    const ui {aka const unsigned int}
answer.code:27:62: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   27 |                 if(abs(t)<=M2)return 1ull*q*(t>>63?mod-inv[-t]:inv[t])%mod;
      |                                                              ^
answer.code:27:55: error: invalid operands of types ‘const ui’ {aka ‘const unsigned int’} and ‘int(int)’ to binary ‘operator-’
   27 |                 if(abs(t)<=M2)return 1ull*q*(t>>63?mod-inv[-t]:inv[t])%mod;
      |                                                    ~~~^~~~~~~~
      |                                                    |         |
      |                                                    |         int(int)
      |                                                    const ui {aka const unsigned int}
answer.code:27:69: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   27 |                 if(abs(t)<=M2)return 1ull*q*(t>>63?mod-inv[-t]:inv[t])%mod;
      |                                                                     ^
answer.code:31:62: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   31 |                 if(abs(t)<=M2)return 1ull*q*(t>>63?mod-inv[-t]:inv[t])%mod;
      |                                                              ^
answer.code:31:55: error: invalid operands of types ‘const ui’ {aka ‘const unsigned int’} and ‘int(int)’ to binary ‘operator-’
   31 |                 if(abs(t)<=M2)return 1ull*q*(t>>63?mod-inv[-t]:inv[t])%mod;
      |                                                    ~~~^~~~~~~~
      |                                                    |         |
      |                                                    |         int(int)
      |                                                    const ui {aka const unsigned int}
answer.code:31:69: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   31 |                 if(abs(t)<=M2)return 1ull*q*(t>>63?mod-inv[-t]:inv[t])%mod;
      |          ...