結果
問題 | No.1666 累乗数 |
ユーザー | Focus_Sash |
提出日時 | 2021-09-03 23:11:33 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,722 bytes |
コンパイル時間 | 4,516 ms |
コンパイル使用メモリ | 264,464 KB |
実行使用メモリ | 16,968 KB |
最終ジャッジ日時 | 2024-12-15 17:30:15 |
合計ジャッジ時間 | 61,792 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 174 ms
10,016 KB |
testcase_01 | TLE | - |
testcase_02 | TLE | - |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | TLE | - |
testcase_09 | TLE | - |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
コンパイルメッセージ
main.cpp:46: warning: "ONLINE_JUDGE" redefined 46 | #define ONLINE_JUDGE | <command-line>: note: this is the location of the previous definition
ソースコード
#include "bits/stdc++.h" #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using vl = vector<long long>; using pl = pair<long long, long long>; struct edge {long long to;long long cost;edge(long long t,long long c):to(t),cost(c){}}; using Graph = vector<vector<long long>>; using WGraph = vector<vector<edge>>; constexpr int dx[8]{1,0,-1,0,1,1,-1,-1}; constexpr int dy[8]{0,1,0,-1,1,-1,1,-1}; #define rep(i, n) for(long long (i) = 0; (i) < (n); (i)++) #define reps(i, a, b) for(long long (i) = (a); (i) < (b); (i)++) #define rrep(i, a, b) for(long long (i) = (a); (i) >= (b); (i)--) #define all(v) (v).begin(), (v).end() #define pb push_back #define V vector constexpr long long MOD1 = 1000000007; constexpr long long MOD9 = 998244353; constexpr long long INF = MOD1*MOD1+1; constexpr long long LL_MAX = std::numeric_limits<long long>::max(); long long safe_mod(long long n, long long m){if(n >= 0) {return n % m;} else return (n%m + m)%m;} long long div_ceil(long long a, long long b){return (a + b - 1) / b;} long long pw(long long x,long long n) {ll ret=1;while(n>0){if(n&1){ret=ret*x;}if(n>>=1){x=x*x;}}return ret;} template<typename T> T SUM(const vector<T> &v){T ret{};return(accumulate(v.begin(), v.end(), ret));} template<typename T> T MAX(const vector<T> &v){return *max_element(v.begin(), v.end());} template<typename T> T MIN(const vector<T> &v){return *min_element(v.begin(), v.end());} template<typename T> T pwmod(T x, long long n, long long m) {T ret=1;while(n>0){if(n&1)ret=ret*x%m;x=x*x%m;n>>=1;}return ret%m;} template<typename T> void rsort(vector<T> &v) {sort(v.begin(), v.end(), greater<T>());} template<typename T> bool chmax(T &a, const T& b) {if(a<b){a=b;return true;}return false;} template<typename T> bool chmin(T &a, const T& b) {if(a>b){a=b;return true;}return false;} template<typename T, typename S> pair<T, S> mp(const T &a, const S &b){return make_pair(a, b);} template<typename T> void uniquify(vector<T> &v){sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());} template<typename T,typename S> ostream&operator<<(ostream&os,const pair<T,S>&p){os<<"("<<p.first<<", "<<p.second<<")";return os;} template<typename T,typename S> ostream&operator<<(ostream&os,const map<T,S>&ma){for(auto [a,b]:ma){os<<"("<<a<<", "<<b<<")"<<" ";}return os;} template<typename T> ostream &operator<<(ostream&os,const set<T>&s){os<<"{";for(auto c:s)os<<c<<" ";os<<"}";return os;} template<typename T> ostream &operator<<(ostream&os,const vector<T>&v){os<<"[";for(int i=0;i<v.size();i++){os<<v[i]<<(i==v.size()-1?"]":" ");}return os;} template<typename T> vector<int> compress(vector<T> &a){ int n = a.size(); vector<int> ret(n); vector<T> temp = a; sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); for(int i = 0; i < n; i++) ret[i] = lower_bound(a.begin(), a.end(), temp[i]) - a.begin(); return ret; } #define ONLINE_JUDGE #ifdef ONLINE_JUDGE #define dump(x) true #else #define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl #endif vector< int > moebius_table(int n) { vector< int > mu(n + 1, 1), p(n + 1, 1); for(int i = 2; i <= n; i++) { if(p[i] == 1) { for(int j = i; j <= n; j += i) p[j] = i; } if((i / p[i]) % p[i] == 0) mu[i] = 0; else mu[i] = -mu[i / p[i]]; } return mu; } ll sqrt_floor(ll n){ assert(n >= 0); if(n == 0 || n == 1) return n; ll ng = n; ll ok = 0; while(ng - ok > 1){ ll mid = (ok + ng) / 2; if(mid <= n / mid) ok = mid; else ng = mid; } return ok; } using lint = __int128; lint pw(lint x, ll n){lint ret=1;while(n>0){if(n&1){ret=ret*x;}if(n>>=1){x=x*x;}}return ret;} void solve(){ ll k; cin >> k; auto table = moebius_table(64); ll ok = 1e18; ll ng = 0; auto count_root = [&](ll n, ll t){ //n以下のt乗数の数 ll ret = 0; for(lint i = 2;; i++){ if(pw(i, t) <= n) ret++; else break; } return ret; }; auto f = [&](ll r) -> bool{ ll cnt = sqrt_floor(r); reps(i, 3, 61){ dump(i); dump(cnt); dump(table[i]); dump(count_root(r, i)); cnt += table[i] * count_root(r, i) * -1; } dump(cnt); return cnt >= k; }; while(ok - ng > 1){ ll mid = (ok + ng) / 2; dump(mid); if(f(mid)) ok = mid; else ng = mid; } cout << ok << '\n'; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << std::fixed << std::setprecision(15); ll cases; cin >> cases; while(cases--) solve(); return 0; }