結果
問題 | No.1653 Squarefree |
ユーザー | tomo0608 |
提出日時 | 2021-08-20 22:59:10 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 747 ms / 2,000 ms |
コード長 | 5,447 bytes |
コンパイル時間 | 5,284 ms |
コンパイル使用メモリ | 281,556 KB |
実行使用メモリ | 68,864 KB |
最終ジャッジ日時 | 2024-10-14 08:33:35 |
合計ジャッジ時間 | 26,362 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 725 ms
68,864 KB |
testcase_01 | AC | 12 ms
5,248 KB |
testcase_02 | AC | 12 ms
5,248 KB |
testcase_03 | AC | 13 ms
5,248 KB |
testcase_04 | AC | 13 ms
5,248 KB |
testcase_05 | AC | 13 ms
5,248 KB |
testcase_06 | AC | 13 ms
5,248 KB |
testcase_07 | AC | 13 ms
5,248 KB |
testcase_08 | AC | 13 ms
5,248 KB |
testcase_09 | AC | 12 ms
5,248 KB |
testcase_10 | AC | 12 ms
5,248 KB |
testcase_11 | AC | 701 ms
66,164 KB |
testcase_12 | AC | 702 ms
66,156 KB |
testcase_13 | AC | 735 ms
68,444 KB |
testcase_14 | AC | 729 ms
68,352 KB |
testcase_15 | AC | 735 ms
68,844 KB |
testcase_16 | AC | 724 ms
68,600 KB |
testcase_17 | AC | 730 ms
68,696 KB |
testcase_18 | AC | 743 ms
68,864 KB |
testcase_19 | AC | 734 ms
68,480 KB |
testcase_20 | AC | 733 ms
68,864 KB |
testcase_21 | AC | 732 ms
68,864 KB |
testcase_22 | AC | 735 ms
68,864 KB |
testcase_23 | AC | 728 ms
68,096 KB |
testcase_24 | AC | 724 ms
68,480 KB |
testcase_25 | AC | 726 ms
68,780 KB |
testcase_26 | AC | 733 ms
68,272 KB |
testcase_27 | AC | 739 ms
68,736 KB |
testcase_28 | AC | 733 ms
68,352 KB |
testcase_29 | AC | 733 ms
68,736 KB |
testcase_30 | AC | 729 ms
68,224 KB |
testcase_31 | AC | 741 ms
68,712 KB |
testcase_32 | AC | 741 ms
68,852 KB |
testcase_33 | AC | 730 ms
68,352 KB |
testcase_34 | AC | 747 ms
68,864 KB |
testcase_35 | AC | 738 ms
68,736 KB |
testcase_36 | AC | 12 ms
5,248 KB |
testcase_37 | AC | 12 ms
5,248 KB |
testcase_38 | AC | 12 ms
5,248 KB |
testcase_39 | AC | 12 ms
5,248 KB |
testcase_40 | AC | 12 ms
5,248 KB |
ソースコード
/** * author: tomo0608 * created: 20.08.2021 21:53:14 **/ #ifdef __LOCAL #define _GLIBCXX_DEBUG #endif #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #if __has_include(<atcoder/all>) #include<atcoder/all> using namespace atcoder; #endif typedef long long ll; typedef long double ld; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; template <class T> using VVV = V<VV<T>>; typedef pair<int,int> pii; typedef pair<long long, long long> pll; #define all(x) x.begin(),x.end() #define SUM(v) accumulate(all(v), 0LL) #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define lb(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define ub(c, x) distance((c).begin(), upper_bound(all(c), (x))) #define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()) template <typename T> void zip(vector<T> &x) {vector<T> y = x;UNIQUE(y);for(int i = 0; i < x.size(); ++i) { x[i] = lb(y, x[i]); }} #define rep1(a) for(long long i = 0; i < a; i++) #define rep2(i, a) for(long long i = 0; i < a; i++) #define rep3(i, a, b) for(long long i = a; i < b; i++) #define rep4(i, a, b, c) for(long long i = a; i < b; i += c) #define drep1(a) for(long long i = a-1; i >= 0; i--) #define drep2(i, a) for(long long i = a-1; i >= 0; i--) #define drep3(i, a, b) for(long long i = a-1; i >= b; i--) #define drep4(i, a, b, c) for(long long i = a-1; i >= b; i -= c) #define overload4(a, b, c, d, e, ...) e #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define drep(...) overload4(__VA_ARGS__, drep4, drep3, drep2, drep1)(__VA_ARGS__) template<class... T>void input(T&... a){(cin >> ... >> a);}; #define INT(...) int __VA_ARGS__; input(__VA_ARGS__) #define LL(...) ll __VA_ARGS__; input(__VA_ARGS__) #define STR(...) string __VA_ARGS__; input(__VA_ARGS__) #define DBL(...) double __VA_ARGS__; input(__VA_ARGS__) void print(){cout << '\n';} template<class T, class... Ts>void print(const T& a, const Ts&... b){cout << a; (cout << ... << (cout << ' ', b)); cout << '\n';} template<class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T> >; template<class T, class U> inline bool chmax(T &a, const U &b) { if (a<b) { a=b; return 1; } return 0; } template<class T, class U> inline bool chmin(T &a, const U &b) { if (a>b) { a=b; return 1; } return 0; } template<class T1, class T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; } template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; } template<class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; } template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; } template<typename T> ostream& operator << (ostream& os, set<T>& set_var) {os << "{"; for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {os << *itr;++itr;if(itr != set_var.end()) os << ", ";itr--;}os << "}";return os;} template <typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &map_var) {os << "{";for(auto itr = map_var.begin(); itr != map_var.end(); itr++) {os << *itr;itr++;if (itr != map_var.end()) os << ", ";itr--;}os << "}";return os;} #ifdef __LOCAL void debug_out(){ cerr << endl;} template < class Head, class... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...);} #define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl #else #define debug(...) (void(0)) #define dump(x) (void(0)) #endif template<class T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r) #define mp make_pair #define bit(n, k) ((n >> k) & 1) /*nのk bit目*/ int topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); } int topbit(ll t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); } int lowbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); } int lowbit(ll a) { return a == 0 ? 64 : __builtin_ctzll(a); } template <typename T>T mypow(T x, ll n){T ret = 1;while(n > 0){if(n & 1)(ret *= x);(x *= x);n >>= 1;}return ret;} #define endl '\n' int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1}; const int MAX = 1000000; void solve(){ LL(l,r); V<bool> is_prime(MAX, true); is_prime[0] = is_prime[1] = false; VV<ll> prime_factors(r-l+1); V<bool> check(r-l+1, true); for(ll p = 2; (p*p*p*p <= r) || (p < MAX); ++p){ if(!is_prime[p])continue; for(ll v = p*2; v < MAX; v += p){ is_prime[v] = false; } for(ll v = (l+p-1)/p*p; v <= r; v += p){ if((v/p)%p == 0)check[v-l] = false; else prime_factors[v-l].emplace_back(p); } } ll res = 0; rep(v,l,r+1){ if(!check[v-l])continue; ll now = v; for(ll p: prime_factors[v-l]){ now /= p; } ll sq = sqrt(now); if(now == 1 || sq * sq != now)res++; } print(res); } int main() { cin.tie(0); ios_base::sync_with_stdio(false); cout << setprecision(20); int codeforces = 1; //cin >> codeforces; while(codeforces--){ solve(); } return 0; }