Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
54956 _ 数对 C++ 运行出错 80 18 MS 4572 KB 1187 2022-08-08 11:35:02

Tests(8/10):


#include <bits/stdc++.h> using namespace std; const int MXN = 1000000; const int END = 500000; int T, N, pms[END], pid, psum[MXN + 5]; bitset<MXN + 5> ivl, eff; int read() { int x(0); char c(getchar()); while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar(); return x; } void write(int x) { if (x >= 10) write(x / 10); putchar((x % 10) | 48); } int main() { // freopen("pair.in", "r", stdin); // freopen("pair.out", "w", stdout); ivl[0] = ivl[1] = true; for (int i(2); i <= END; ++i) { if (!ivl[i]) { pms[pid++] = i; } if (eff[i]) for (int j(0), x(0); j != pid && (x = i * pms[j]) <= MXN; ++j) { ivl[x] = true; eff[x] = 1; if (!(i % pms[j])) { break; } } else for (int j(0), x(0); j != pid && (x = i * pms[j]) <= MXN; ++j) { ivl[x] = true; if (!(i % pms[j])) { eff[x] = 1; break; } } } for (int i(2); i <= MXN; ++i) { psum[i] = psum[i - 1] + eff[i]; } T = read(); while (T--) { N = read(); write(psum[N]); putchar(10); } // cout << clock() / 1000.0 << endl; return 0; }


测评信息: