QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#649617 | #9309. Graph | fosov | WA | 1ms | 7684kb | C++14 | 3.1kb | 2024-10-18 03:45:13 | 2024-10-18 03:45:15 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353
#define pii pair<int, int>
template<int M>
struct modint {
int val;
modint(): val(0) {};
modint(ll val): val(val % M) {};
modint operator+(modint o) {
return modint(((ll) val + o.val) % M);
}
modint operator-(modint o) {
return modint(((ll) val - o.val + M) % M);
}
modint operator*(modint o) {
return modint((ll) val * o.val % M);
}
modint operator/(modint o) {
return *this * o.pow(M-2);
}
modint pow(ll p) {
modint b = *this, c = modint(1);
for (; p; b=b*b, p>>=1) if (p&1) c=c*b;
return c;
}
};
template<int M>
ostream& operator<<(ostream& os, const modint<M>& s) {
return os << s.val;
}
#define mint modint<MOD>
struct min25 {
static const int N = 2000010;
ll n, m, s;
ll bk[N], g[N];
int pc, p[N], ip[N];
static ll isqrt(ll x) {
ll l = 1, r = x;
while (l < r) {
ll m = (l + r) / 2;
if (m < x / m) {
l = m+1;
} else {
r = m;
}
}
return r - (r * r > x);
}
void linear_sieve(int x) {
pc = p[0] = 1;
for (int i = 1; i < x; ++ i) ip[i] = 1;
for (int i = 2; i < x; ++ i) {
if (ip[i]) p[pc ++] = i;
for (int j = 1; j < pc && (ll) i * p[j] < x; ++ j) {
ip[i * p[j]] = 0;
if (i % p[j] == 0) break;
}
}
}
int get_id(ll x) {
return x <= s ? x - 1 : m - n / x;
}
void init(ll n) {
this->n = n;
m = 0;
s = isqrt(n);
cout << s << '\n';
linear_sieve(s + 1);
// for (int i = 1; i <= s; ++ i) bk[m ++] = i;
// for (int i = s; i >= 1; -- i) if (n / i > s) bk[m ++] = n / i;
// for (int i = 0; i < m; ++ i) g[i] = bk[i] - 1;
// for (int i = 1, bi = 0; i < pc; ++ i) {
// while (1ll * p[i] * p[i] > bk[bi]) ++ bi;
// for (int j = m-1; j >= bi; -- j) {
// g[j] = g[j] - 1ll * (g[get_id(bk[j] / p[i])] - g[get_id(p[i-1])]);
// }
// }
}
int cnt_prime(ll x) {
if (x == 0) return 0;
assert(bk[get_id(x)] == x);
return g[get_id(x)];
}
} sieve;
int main() {
#ifdef TEST
freopen("zz.in", "r+", stdin);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n; cin >> n;
sieve.init(n);
ll l = 1;
mint res = mint(1);
while (l <= n) {
ll r = n / (n / l);
ll m = n / l;
// int np = sieve.cnt_prime(m) - sieve.cnt_prime(m / 2);
// int k = 1 + np + (m - 1 - np != 0);
// mint mu = mint(max(m - 1 - np, 1ll));
// mint cur = mu * mint(m).pow(max(0, k - 2));
// res = res * cur.pow(r - l + 1);
l = r+1;
}
cout << res << '\n';
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7684kb
input:
4
output:
2 1
result:
wrong answer expected '8', found '2'