Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***
- created: 2022-08-29-01.49.51
- ***/
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace std;
- using namespace __gnu_pbds;
- template<typename U> using ordered_set=tree<U, null_type,less<U>,rb_tree_tag,tree_order_statistics_node_update>;
- #define ll long long
- #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
- #define get_lost_idiot return 0
- #define nl '\n'
- vector<ll>divs(ll x)
- {
- vector<ll>a;
- for(ll i=1;i*i<=x;i++)
- {
- if(x%i==0)
- {
- a.push_back(x/i);
- if(i*i!=x) a.push_back(i);
- }
- }
- return a;
- }
- double dp[100005];
- bool v[100005];
- double solve(ll n)
- {
- if(n==1) return dp[1]=0.00;
- if(v[n]) return dp[n];
- vector<ll>dv=divs(n);
- v[n]=1;
- double ans=0.00;
- for(ll i=0;i<dv.size();i++)
- {
- ans+=(solve(n/dv[i])*1.00 + 1.00) / (dv.size()-1)*1.00;
- }
- //ans+=(dv.size() * 1.00)/((dv.size()-1)*1.00);
- return dp[n]=ans;
- }
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- test
- {
- ll n,m,i,j,k,l;
- cin>>n;
- // for(i=0;i<100004;i++)
- // {
- // v[i]=0,dp[i]=0.00;
- // }
- cout<<"Case "<<cs<<": "<<fixed<<setprecision(10)<<solve(n)<<nl;
- }
- get_lost_idiot;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement