結果
問題 | No.1666 累乗数 |
ユーザー | tko919 |
提出日時 | 2021-09-04 00:20:57 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 1,313 bytes |
コンパイル時間 | 2,389 ms |
コンパイル使用メモリ | 204,724 KB |
実行使用メモリ | 12,484 KB |
最終ジャッジ日時 | 2023-08-22 02:56:03 |
合計ジャッジ時間 | 6,076 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
11,500 KB |
testcase_01 | AC | 128 ms
11,384 KB |
testcase_02 | AC | 129 ms
12,208 KB |
testcase_03 | AC | 128 ms
12,308 KB |
testcase_04 | AC | 128 ms
11,288 KB |
testcase_05 | AC | 127 ms
11,252 KB |
testcase_06 | AC | 128 ms
11,704 KB |
testcase_07 | AC | 128 ms
11,860 KB |
testcase_08 | AC | 128 ms
11,388 KB |
testcase_09 | AC | 127 ms
11,452 KB |
testcase_10 | AC | 129 ms
12,024 KB |
testcase_11 | AC | 127 ms
11,616 KB |
testcase_12 | AC | 128 ms
11,808 KB |
testcase_13 | AC | 129 ms
12,104 KB |
testcase_14 | AC | 129 ms
11,468 KB |
testcase_15 | AC | 129 ms
11,304 KB |
testcase_16 | AC | 128 ms
12,452 KB |
testcase_17 | AC | 129 ms
11,944 KB |
testcase_18 | AC | 128 ms
12,484 KB |
testcase_19 | AC | 128 ms
11,972 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:46:13: 警告: ‘add’ may be used uninitialized [-Wmaybe-uninitialized] 46 | cnt+=add; | ~~~^~~~~ main.cpp:44:27: 備考: ‘add’ はここで定義されています 44 | ll sub=sqrt(mid),add; | ^~~
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; //template #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() using ll=long long int; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;} template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} const ll LIM=1000000000000000000LL; int main(){ vector<ll> other; for(ll a=2;a<=1000001;a++){ ll add=a*a; rep(_,0,65){ if(add>=LIM/a)break; add*=a; { ll sq=sqrt(add); rep(off,-5,5)if(ll(sq+off)*(sq+off)==add)goto fail; other.push_back(add); fail:; } } } sort(ALL(other)); other.erase(unique(ALL(other)),other.end()); int q; cin>>q; while (q--) { int x; cin>>x; x--; ll lb=0,rb=LIM+5; while(rb-lb>1){ ll mid=(lb+rb)>>1; ll cnt=upper_bound(ALL(other),mid)-other.begin(); ll sub=sqrt(mid),add; rep(off,-5,5)if(ll(sub+off)*(sub+off)<=mid)add=sub+off; cnt+=add; if(cnt>x)rb=mid; else lb=mid; } cout<<rb<<'\n'; } return 0; }