結果
| 問題 |
No.2829 GCD Divination
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-02 23:10:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 645 bytes |
| コンパイル時間 | 1,897 ms |
| コンパイル使用メモリ | 194,364 KB |
| 最終ジャッジ日時 | 2025-02-23 20:24:04 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 TLE * 5 |
ソースコード
#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)/(i-1);
for(int j=i*2;j<=N;j+=i){
dp[j]+=phi[j/i]/j*(dp[i]+1);
}
}
cout<<setprecision(10)<<dp[N]<<'\n';
}