提交记录 185762
| 提交时间 |
评测时间 |
| 2026-11-27 13:31:35 |
2026-11-27 13:31:38 |
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
constexpr int N = 100000000,P = 6000000,S = 10000,W = 64,B = 18;
struct node
{
ull data[1 << B - 6];
void clear() {memset(data,0xff,sizeof data);}
bool get(int pos) {return data[pos >> 6] & (1ull << (pos & 63));}
void set(int pos) {data[pos >> 6] &= (ull)-1 ^ 1ull << (pos & 63);}
void solve(int l);
}tool;
int pl[P],ptop,rtop;
void node::solve(int l)
{
int e = l + (1 << B);
clear();
for(int i = 1;pl[i] * pl[i] < e;i++)
for(int j = max(pl[i],(l - 1) / pl[i] + 1) * pl[i];j < e;j += pl[i])
set(j - l);
for(int i = 0;i < 1 << B - 6;i++)
while(data[i])
{
int b = __builtin_ctzll(data[i]);
pl[++ptop] = l + (i << 6) + b;
data[i] ^= 1ull << b;
}
}
void premake()
{
tool.clear();
tool.set(0),tool.set(1);
for(int i = 2;i <= S;i++)
if(tool.get(i))
for(int j = i * i;j < 1 << B;j += i)
tool.set(j);
for(int i = 0;i < 1 << B - 6;i++)
while(tool.data[i])
{
int b = __builtin_ctzll(tool.data[i]);
pl[++ptop] = (i << 6) + b;
tool.data[i] ^= 1ull << b;
}
for(int l = 1 << B;l < N;l += 1 << B)
tool.solve(l);
}
void sieve(uint64_t n, char *s)
{
premake();
memset(s,0,N / 8 + 1);
uint8_t *ans = (uint8_t *)s;
for(int i = 1;i <= ptop && pl[i] < N;i++)
{
// assert(prime[i] < N);
ans[pl[i] >> 3] |= 1 << (pl[i] & 7);
}
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 296.31 ms | 33 MB + 1020 KB | Accepted | Score: 100 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-11-30 11:50:30 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠