結果
| 問題 |
No.2829 GCD Divination
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-02 21:35:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 615 bytes |
| コンパイル時間 | 911 ms |
| コンパイル使用メモリ | 86,848 KB |
| 実行使用メモリ | 61,848 KB |
| 最終ジャッジ日時 | 2024-08-02 21:35:59 |
| 合計ジャッジ時間 | 14,264 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 TLE * 2 |
ソースコード
#include<iostream>
#include<vector>
#include<map>
#include<cassert>
#include<iomanip>
using namespace std;
int gcd(int a,int b)
{
while(b)
{
int t=a%b;
a=b;
b=t;
}
return a;
}
map<int,long double>memo;
long double solve(int N)
{
if(N==1)return 0;
if(memo.find(N)!=memo.end())return memo[N];
vector<int>to(N,1);
for(int g=2;g<N;g++)if(N%g==0)for(int i=g;i<N;i+=g)to[i]=g;
long double ans=0;
for(int i=1;i<N;i++)ans+=solve(to[i]);
ans+=N;
ans/=N-1;
return memo[N]=ans;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;cin>>N;
cout<<fixed<<setprecision(16)<<solve(N)<<endl;
}