結果
問題 | No.1666 累乗数 |
ユーザー |
![]() |
提出日時 | 2021-09-03 21:57:02 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,798 ms / 2,000 ms |
コード長 | 1,261 bytes |
コンパイル時間 | 924 ms |
コンパイル使用メモリ | 56,576 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-15 13:04:44 |
合計ジャッジ時間 | 34,281 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
6,820 KB |
testcase_01 | AC | 1,657 ms
6,816 KB |
testcase_02 | AC | 1,673 ms
6,816 KB |
testcase_03 | AC | 1,669 ms
6,816 KB |
testcase_04 | AC | 1,688 ms
6,816 KB |
testcase_05 | AC | 1,784 ms
6,820 KB |
testcase_06 | AC | 1,789 ms
6,816 KB |
testcase_07 | AC | 1,761 ms
6,816 KB |
testcase_08 | AC | 1,798 ms
6,824 KB |
testcase_09 | AC | 1,679 ms
6,816 KB |
testcase_10 | AC | 1,684 ms
6,820 KB |
testcase_11 | AC | 1,667 ms
6,820 KB |
testcase_12 | AC | 1,668 ms
6,816 KB |
testcase_13 | AC | 1,779 ms
6,816 KB |
testcase_14 | AC | 1,722 ms
6,816 KB |
testcase_15 | AC | 1,761 ms
6,816 KB |
testcase_16 | AC | 1,741 ms
6,824 KB |
testcase_17 | AC | 1,675 ms
6,816 KB |
testcase_18 | AC | 1,691 ms
6,816 KB |
testcase_19 | AC | 1,735 ms
6,820 KB |
ソースコード
#include <stdio.h> #include <vector> #include <map> #define MAX (long long int)1e18 int check[110]; std::vector<int> prime; std::map<long long int, long long int> M; long long int func(int k, int mul,long long int val) { if(mul>60) return 0; if(k==prime.size()) { if(mul==1) return 0; long long int min = 1, max = val; long long int p = 1; if(mul>=20) max = 10; else if(mul>=10) max = 100; else if(mul>=6) max = 1000; else if(mul>=3) max = 1000000; else max = 1000000000; while(min<=max) { long long int h = (min+max)/2; long long int t = val; for(int i=1;i<=mul;i++) t/=h; if(t==0) max = h-1; else { p = h; min = h+1; } } return p-1; } long long int s1 = func(k+1,mul,val); long long int s2 = func(k+1,mul*prime[k],val); return s1-s2; } int main() { for(int i=2;i<=60;i++) { if(check[i]==0) { prime.push_back(i); for(int j=i;j<=60;j+=i) check[j] = 1; } } int T; scanf("%d",&T); while(T--) { int a; scanf("%d",&a); long long int min = 1, max = MAX; long long int ans = MAX; while(min<=max) { long long int h = (min+max)/2; long long int s = -func(0,1,h)+1; if(s>=a) { ans = h; max = h-1; } else min = h+1; } printf("%lld\n",ans); } }