QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#134752 | #5. 在线 O(1) 逆元 | sserxhs | Compile Error | / | / | C++14 | 869b | 2023-08-04 20:42:53 | 2024-11-05 21:51:04 |
Judging History
你现在查看的是最新测评结果
- [2024-11-05 21:51:04]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-08-04 20:43:10]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-04 20:42:53]
- 提交
answer
namespace online_inv
{
typedef unsigned int ui;
typedef unsigned long long ll;
const ui p=1e9+7;
const ui n=1010,m=n*n,N=m+2;
int l[N],r[N];
ui y[N];
bool s[N];
ui _inv[N*2],i,j,k;
void init_inv()
{
assert(n*n*n>p);
_inv[1]=1;
for (i=2;i<m*2;i++)
{
j=p/i;
_inv[i]=(ll)(p-j)*_inv[p-i*j]%p;
}
s[0]=y[0]=1;
for (i=1;i<n;i++) for (j=i;j<n;j++) if (!s[k=i*m/j])
{
y[k]=j;
s[k]=1;
}
l[0]=1;
for (i=1;i<=m;i++) l[i]=s[i]?y[i]:l[i-1];
r[m]=1;
for (i=m-1;~i;i--) r[i]=s[i]?y[i]:r[i+1];
for (i=0;i<=m;i++) y[i]=min(l[i],r[i]);
}
inline ui inv(const ui &x)
{
assert(x&&x<p);
if (x<m*2) return _inv[x];
k=(ll)x*m/p;
j=(ll)y[k]*x%p;
return (j<m*2?_inv[j]:p-_inv[p-j])*(ll)y[k]%p;
}
}
using online_inv::init_inv,online_inv::inv,online_inv::p;
void init(int p)
{
init_inv();
}
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 online_inv::init_inv()’: answer.code:13:17: error: ‘assert’ was not declared in this scope 13 | assert(n*n*n>p); | ^~~~~~ answer.code:1:1: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’? +++ |+#include <cassert> 1 | namespace online_inv answer.code:30:41: error: ‘min’ was not declared in this scope 30 | for (i=0;i<=m;i++) y[i]=min(l[i],r[i]); | ^~~ answer.code: In function ‘online_inv::ui online_inv::inv(const ui&)’: answer.code:34:17: error: ‘assert’ was not declared in this scope 34 | assert(x&&x<p); | ^~~~~~ answer.code:34:17: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’? answer.code: At global scope: answer.code:41:27: warning: comma-separated list in using-declaration only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 41 | using online_inv::init_inv,online_inv::inv,online_inv::p; | ^ answer.code:41:43: warning: comma-separated list in using-declaration only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 41 | using online_inv::init_inv,online_inv::inv,online_inv::p; | ^