結果
問題 | No.1653 Squarefree |
ユーザー | XD |
提出日時 | 2021-11-10 20:06:27 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 66 ms / 2,000 ms |
コード長 | 2,995 bytes |
コンパイル時間 | 1,673 ms |
コンパイル使用メモリ | 168,172 KB |
実行使用メモリ | 19,040 KB |
最終ジャッジ日時 | 2024-05-01 08:17:35 |
合計ジャッジ時間 | 4,861 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 66 ms
17,296 KB |
testcase_01 | AC | 19 ms
10,568 KB |
testcase_02 | AC | 20 ms
10,568 KB |
testcase_03 | AC | 19 ms
10,444 KB |
testcase_04 | AC | 19 ms
10,568 KB |
testcase_05 | AC | 19 ms
12,568 KB |
testcase_06 | AC | 19 ms
14,624 KB |
testcase_07 | AC | 20 ms
10,700 KB |
testcase_08 | AC | 20 ms
12,704 KB |
testcase_09 | AC | 19 ms
10,572 KB |
testcase_10 | AC | 19 ms
12,700 KB |
testcase_11 | AC | 57 ms
17,936 KB |
testcase_12 | AC | 56 ms
17,788 KB |
testcase_13 | AC | 62 ms
17,696 KB |
testcase_14 | AC | 63 ms
18,892 KB |
testcase_15 | AC | 65 ms
17,872 KB |
testcase_16 | AC | 66 ms
18,164 KB |
testcase_17 | AC | 63 ms
17,432 KB |
testcase_18 | AC | 65 ms
19,040 KB |
testcase_19 | AC | 64 ms
18,708 KB |
testcase_20 | AC | 63 ms
17,496 KB |
testcase_21 | AC | 63 ms
18,004 KB |
testcase_22 | AC | 65 ms
17,688 KB |
testcase_23 | AC | 66 ms
17,096 KB |
testcase_24 | AC | 64 ms
17,524 KB |
testcase_25 | AC | 63 ms
17,528 KB |
testcase_26 | AC | 63 ms
17,568 KB |
testcase_27 | AC | 65 ms
17,628 KB |
testcase_28 | AC | 63 ms
17,140 KB |
testcase_29 | AC | 65 ms
18,052 KB |
testcase_30 | AC | 65 ms
17,224 KB |
testcase_31 | AC | 62 ms
17,728 KB |
testcase_32 | AC | 65 ms
17,600 KB |
testcase_33 | AC | 62 ms
17,124 KB |
testcase_34 | AC | 63 ms
18,844 KB |
testcase_35 | AC | 62 ms
17,448 KB |
testcase_36 | AC | 20 ms
10,696 KB |
testcase_37 | AC | 19 ms
10,568 KB |
testcase_38 | AC | 20 ms
12,828 KB |
testcase_39 | AC | 19 ms
10,568 KB |
testcase_40 | AC | 19 ms
10,444 KB |
ソースコード
#include <bits/stdc++.h> #define forn(i,s,t) for(register int i=(s); i<=(t); ++i) #define forl(i,s,t) for(register i64 i=(s); i<=(t); ++i) #define form(i,s,t) for(register int i=(s); i>=(t); --i) #define rep(i,s,t) for(register int i=(s); i<(t); ++i) #define IT(u) for(register int i=G[u]; i; i=E[i].nxt) using namespace std; namespace FASTIO { const int SIZ = 1 << 26 | 1; char ibuf[SIZ], obuf[SIZ], *iS = ibuf, *iT = ibuf, *oS = obuf, *oT = obuf + SIZ - 1, qwq[60], qaq; #define gc() (iS == iT && (iT = (iS = ibuf) + fread(ibuf, 1, SIZ, stdin), iS == iT) ? EOF : *iS++) template<typename T> inline void Rdn(T& A) { register bool fl = 0; register char ch = gc(); A = 0; while(!isdigit(ch)) fl = (ch == '-'), ch = gc(); while(isdigit(ch)) A = (A * 10) + (ch & 15), ch = gc(); fl && (A = -A); } inline void Rdn(char& c) {while((c = gc()) == ' ' || c == '\n' || c == '\r');} inline void Rdn(char* s) { while((*s = gc()) == ' ' || *s == '\n' || *s == '\r') ; if(*s == EOF) return ; while(*s != ' ' && *s != '\n' && *s != '\r' && *s != EOF) *(++s) = gc(); *s = 0; } template<typename T, typename ...U> inline void Rdn(T& A, U& ...B) {Rdn(A), Rdn(B...);} inline void flush() {fwrite(obuf, 1, oS - obuf, stdout), oS = obuf;} inline void pc(char c) {*oS ++ = c; if(oS == oT) flush();} template<typename T> inline void Wtn(T A) { if(!A) return pc('0'); if(A < 0) pc('-'), A = -A; while(A) qwq[++qaq] = A % 10 + '0', A /= 10; while(qaq) pc(qwq[qaq -- ]); } inline void Wtn(char A) {pc(A);} inline void Wtn(char *s) {while(*s) pc(*s), ++s;} inline void Wtn(const char *s) {while(*s) pc(*s), ++s;} template<typename T, typename ...U> inline void Wtn(T A, U ...B) {Wtn(A), Wtn(B...);} #undef gc } using FASTIO :: Rdn; using FASTIO :: Wtn; using FASTIO :: flush; typedef long long i64; typedef double f64; typedef unsigned long long u64; typedef pair<i64, i64> pii; typedef pair<int, u64> piu; const int N = 1e6 + 5; const i64 INF = 1e18; inline void init() {} int tot; bool vis[N]; i64 p[N], sp[N]; inline void table(int lim) { forn (i, 2, lim) { if (!vis[i]) p[++tot] = i, sp[tot] = 1ll * i * i; for (int j = 1; j <= tot && i * p[j] <= lim; ++j) { vis[i * p[j]] = 1; if (i % p[j] == 0) break ; } } } i64 L, R; i64 ans[N]; inline void solve() { Rdn(L, R), table(1000000); rep (i, 0, R - L + 1) ans[i] = L + i; forn (i, 1, tot) for (i64 j = ((L + sp[i] - 1) / sp[i]) * sp[i]; j <= R; j += sp[i]) ans[j - L] = -1; forn (i, 1, tot) for (i64 j = ((L + p[i] - 1) / p[i]) * p[i]; j <= R; j += p[i]) if (ans[j - L] != -1) ans[j - L] /= p[i]; // rep (i, 0, R - L + 1) Wtn(ans[i], " \n"[i == R - L]); rep (i, 0, R - L + 1) if (ans[i] != -1) { if (ans[i] != 1 && (i64)sqrtl(ans[i]) * (i64)sqrtl(ans[i]) == ans[i]) ans[i] = -1; } // rep (i, 0, R - L + 1) Wtn(ans[i], " \n"[i == R - L]); int res = 0; rep (i, 0, R - L + 1) res += (ans[i] != -1); Wtn(res, '\n'); } int Trd; int main() { Trd = 1; while(Trd--) init(), solve(); flush(); return 0; }