結果
問題 | No.2829 GCD Divination |
ユーザー | Nzt3 |
提出日時 | 2024-08-02 23:15:08 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,853 ms / 2,000 ms |
コード長 | 665 bytes |
コンパイル時間 | 2,257 ms |
コンパイル使用メモリ | 203,456 KB |
実行使用メモリ | 159,852 KB |
最終ジャッジ日時 | 2024-08-02 23:15:36 |
合計ジャッジ時間 | 27,104 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 1,853 ms
159,836 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 1,806 ms
159,852 KB |
testcase_05 | AC | 1,543 ms
138,452 KB |
testcase_06 | AC | 1,168 ms
116,044 KB |
testcase_07 | AC | 1,010 ms
105,016 KB |
testcase_08 | AC | 557 ms
70,956 KB |
testcase_09 | AC | 395 ms
59,760 KB |
testcase_10 | AC | 803 ms
90,660 KB |
testcase_11 | AC | 13 ms
7,296 KB |
testcase_12 | AC | 130 ms
31,512 KB |
testcase_13 | AC | 1,588 ms
143,048 KB |
testcase_14 | AC | 905 ms
97,240 KB |
testcase_15 | AC | 542 ms
70,908 KB |
testcase_16 | AC | 157 ms
35,200 KB |
testcase_17 | AC | 68 ms
20,624 KB |
testcase_18 | AC | 41 ms
15,860 KB |
testcase_19 | AC | 93 ms
25,536 KB |
testcase_20 | AC | 2 ms
6,944 KB |
testcase_21 | AC | 405 ms
60,088 KB |
testcase_22 | AC | 511 ms
71,636 KB |
testcase_23 | AC | 726 ms
84,360 KB |
testcase_24 | AC | 1,294 ms
126,428 KB |
testcase_25 | AC | 1,751 ms
154,864 KB |
testcase_26 | AC | 447 ms
67,044 KB |
testcase_27 | AC | 1,103 ms
115,708 KB |
testcase_28 | AC | 107 ms
26,524 KB |
testcase_29 | AC | 517 ms
72,200 KB |
testcase_30 | AC | 1,620 ms
148,852 KB |
testcase_31 | AC | 71 ms
20,612 KB |
testcase_32 | AC | 784 ms
88,464 KB |
testcase_33 | AC | 454 ms
64,424 KB |
testcase_34 | AC | 1,143 ms
115,184 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; constexpr int MOD=998244353; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep2(i,l,r) for(int i=(l);i<(int)(r);i++) int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; vector phi(N+1,0.0); for(int i=0;i<=N;i++)phi[i]=i; for(int i=2;i<=N;i++){ if(phi[i]!=i)continue; for(int j=i;j<=N;j+=i){ phi[j]=phi[j]/i*(i-1); } } vector dp(N+1,0.0); for(int i=1;i<=N;i++){ if(i>1)dp[i]=(1+dp[i]*i)/(double)(i-1); for(int j=2;j*i<=N;j++){ dp[j*i]+=phi[j]*(dp[i]+1)/((double)j*i); } } cout<<setprecision(10)<<dp[N]<<'\n'; }