Tribles UVA - 11021
题意
占位 ing。。。。。。
思路
代码
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <bitset>
#include <vector>
using namespace std;
void fre() { system("clear"), freopen("A.txt", "r", stdin); freopen("Ans.txt","w",stdout); }
void Fre() { system("clear"), freopen("A.txt", "r", stdin);}
void Run(int x = 0) {
#ifdef ACM //宏定义免注释 freopen
if(! x) fre(); else Fre();
#endif
}
#define ios ios::sync_with_stdio(false)
#define Pi acos(-1)
#define pb push_back
#define fi first
#define se second
#define db double
#define ll long long
#define ull unsigned long long
#define Pir pair<ll, ll>
#define m_p make_pair
#define for_(i, s, e) for(ll i = (ll)(s); i <= (ll)(e); i ++)
#define rep_(i, e, s) for(ll i = (ll)(e); i >= (ll)(s); i --)
#define memset(a, b, c) memset(a, (int)b, c);
#define size() size() * 1LL
#define sc scanf
#define pr printf
#define sd(a) sc("%lld", &a)
#define ss(a) sc("%s", a)
#define __ pr( "------------------------\n" );
#define ___ pr("\n------------------------\n");
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define esp 1e-7
#define mod (ll)(1e9 + 7)
/*=========================ACMer===========================*/
const ll mxn = 1e5;
db dp[mxn + 10];
vector<ll> fac;
void get_fac(ll n)
{
fac.clear();
for (ll i = 1; i * i <= n; i ++)
{
if(n % i == 0)
{
fac.pb(i);
if(n / i != i)
fac.pb(n / i);
}
}
}
void pre_do()
{
dp[1] = 0;
for_(i, 2, mxn)
{
get_fac(i);
for (auto x : fac)
{
dp[i] += dp[x];
}
dp[i] = (dp[i] + fac.size()) / (fac.size() - 1);
}
}
int main()
{
Run();
pre_do();
ll T, cas = 1; sd(T);
while(T --)
{
ll n; sd(n);
pr("Case %lld: %f\n", cas ++, dp[n]);
}
return 0;
}