QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#217122 | #5. 在线 O(1) 逆元 | Starrykiller | 70 | 2480ms | 3580kb | C++23 | 308b | 2023-10-16 15:13:27 | 2023-10-16 15:13:27 |
Judging History
answer
#include "inv.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int p;
void init(int mod) {p=mod;}
ll qpow(ll a, ll n) {
ll res=1;
while (n) {
if (n&1) res=res*a%p;
a=a*a%p; n>>=1;
}
return res;
}
int inv(int x) {
ll res=qpow(x,p-2);
return int(res);
}
Details
Test #1:
score: 30
Accepted
time: 25ms
memory: 3540kb
Test #2:
score: 40
Accepted
time: 2480ms
memory: 3580kb
Test #3:
score: 0
Time Limit Exceeded