Problem:
Problem B:
Divisor Function
Teiji is a number theory lover. All numbers are his friends - so long as they are integers. One day, while
preparing for the next class as a teaching assistant, he is interested in a number-theoretical function called the
divisor function
. The divisor function
σ
(
n
) is defined as the sum of all positive divisors of
n
. “How fast does this
σ
(
n
) grow?” he asked himself. Apparently,
σ
(
n
) grows fast as
n
increases, but it is hard to estimate the speed of
the growth. He decided to calculate the maximum value of
σ
(
n
)/
n
on 1 ≤
n
≤
k
, for various
k
.
While it is easy for small numbers, it is tough to calculate many values of the divisor function by hand. Tired of
writing thousands of digits, he decided to solve the problem with the help of a computer. But there is a problem:
he is not familiar with computer programming. He asked you, a talented programmer, for help.
Please write a program to help him.
Input
The input contains a series of test cases. Each test case is described by a line, which contains a single integer
k
(1 ≤
k
≤ 10
15
). The input ends with a line containing a zero, which should not be processed.
Output
For each test case, output the maximum value of
σ
(
n
)/
n
where 1 ≤
n
≤
k
in a line. Each value should be printed
with six digits after the decimal point, and should not contain an absolute error greater than 10
-6
.
Sample Input
1
2
3
10
50
0
Output for the Sample Input
1.000000
1.500000
1.500000
2.000000
2.583333

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
#define ll long long

using namespace std;
const int N = 33;

ll k;
bool prime[N];
vector<int> p;

void sieve() {
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1] = false;
    for (int i = 2; i * i <= N; i++) {
        if (prime[i]) {
            for (int j = i * i; j <= N; j += i) {
                prime[j] = false;
            }
        }
    }
    for (int i = 2; i < N; i++) if (prime[i]) p.push_back(i);
}

double backtrack(int j, ll n, ll sum) {
    if (j == p.size()) return (double)sum / n;
    ll cur = sum;
    double ans = 0;
    for (int i = 0; i < 50; i++) {
        ans = max(ans, backtrack(j + 1, n, cur));
        n *= p[j];
        if (n > k) break;
        cur = cur * p[j] + sum;
    }
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    sieve();
    while (cin >> k) {
        if (!k) break;
        double ans = backtrack(0, 1, 1);
        cout << fixed << setprecision(6) << ans << '\n';
    }
    return 0;
}
//:)
accuracy: 1
time_ms: 580
memory_kb: 3468
final_rank: 10

code_snippet: #include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <numeric>
#include <climits>
#include <cfloat>

std::vector<int> primes(const int upper) {
	std::vector<bool> is_prime(upper + 1, true);
	for (auto i = 2; i * i <= upper; ++i) {
		if (is_prime[i]) for (auto j = i * i; j <= upper; j += i) {
			is_prime[j] = false;
		}
	}
	std::vector<int> result;
	for (auto i = 2; i <= upper; ++i) if (is_prime[i]) result.push_back(i);
	return result;
}
long double sigma(const std::vector<int>& prime, const int p, const long long int current, const long long int limit, const long double result) {
	if (limit / prime[p] < current) {
		return result / current;
	}
	else {
		long double max = result / current;
		for (long long int factor = prime[p]; limit >= current * factor; factor *= prime[p]) {
			auto temp = sigma(prime, p + 1, current * factor, limit, result * (factor * prime[p] - 1) / (prime[p] - 1LL));
			if (max < temp) max = temp;
		}
		return max;
	}
}
int main() {
	const auto prime = primes(1000);
	std::cout << std::setprecision(10) << std::fixed;
	while (true) {
		long long int n; std::cin >> n;
		if (n == 0) return 0;
		std::cout << sigma(prime, 0, 1, n, 1) << std::endl;
	}
}
accuracy: 1
time_ms: 20
memory_kb: 3200
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

// 2*3*5*7*11*13*17*19*23*29*31*37*41
// = 304,250,263,527,210

const int P = 13;
ll p[P]={2,3,5,7,11,13,17,19,23,29,31,37,41};

double calc(ll n){
    ll div = n;
    ll s = 1;
    rep(i,P){

        ll mul = 1;
        ll now = 1;
        while(n%p[i]==0){
            n /= p[i];
            now *= p[i];
            mul += now;
        }
        s *= mul;
    }

    return (double)s/div;
}

const ll LIM = 1000000000000010LL;
map<ll,double> memo;

void dfs(ll v, int idx, int nowct, int prect){
    if(v > LIM) return;
    if(idx == P) return;

    if(!memo.count(v)) memo[v] = calc(v);

    if(prect > nowct) dfs(v*p[idx], idx, nowct+1, prect);
    dfs(v, idx+1, 0, nowct);
}

int main(){
    dfs(1,0,0,50);

    double val = 0;
    vector<ll> v;
    vector<double> a;
    for(const auto &pp:memo){
        if(pp.se > val){
            val = pp.se;
            v.pb(pp.fi);
            a.pb(pp.se);
        }
    }
    v.pb(LIM);

    ll k;
    while(cin >>k,k){
        int idx = upper_bound(all(v), k) - v.begin();
        printf("%.10f\n", a[idx-1]);
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4024
final_rank: 8

code_snippet: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int k;
double ans;

template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;};

vector<Int> pr;

Int isprime(Int x){
  if(x<=1) return 0;
  for(Int i=2;i*i<=x;i++)
    if(x%i==0) return 0;
  return 1;
}

void dfs(Int x,double y,Int p,Int c){
  //if(x<=k) cout<<y<<" "<<x<<":"<<(y/x)<<endl; 
  if(x<=k) chmax(ans,y/x);
  else return;
  Int t=1;
  double s=0;
  if(c==0) return;
  for(Int i=0;i<=c;i++){
    if(x>k/t) break;
    s+=t;
    dfs(x*t,y*s,p+1,i);
    if(t>k/pr[p]) break; 
    t*=pr[p];
  }
} 

struct Precision{
  Precision(){
    cout<<fixed<<setprecision(6);
  }
}precision_beet;

signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  
  for(Int i=2;i<1e5;i++) if(isprime(i)) pr.emplace_back(i);
  
  while(cin>>k,k){
    ans=1;
    dfs(1,1,0,100);
    cout<<ans<<endl;
  } 
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3420
final_rank: 7

code_snippet: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

using ld= long double;

vector<int>primes;
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	vector<int>sos;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes.push_back(i);
		}
	}
	flag = true;
}

long long int K;

ld solve(long long int now_num,int pr_id,int use_max,ld now_val) {
	if (use_max == 0) {
		return now_val;
	}
	if (primes.size() == pr_id) {
		return now_val;
	}
	else {
		ld ans=now_val;
		int now_use = 0;
		long long int pr_sum=1;
		long long int div_sum=1;
		ld next_val=now_val*pr_sum/div_sum;
		long long int next_num=now_num;
		while (next_num<=K) {
			ans=max(ans,solve(next_num,pr_id+1,now_use,next_val));

			now_use++;
			div_sum*=primes[pr_id];
			pr_sum+=div_sum;
			next_val=now_val*pr_sum/div_sum;
			next_num*=primes[pr_id];
		}

		return ans;
	}
}
int main() {
	hurui(1e3);
	int case_id=0;
	while (true) {
		cin>>K;
		if(!K)break;
		ld ans=solve(1,0,1000,1);
		cout<<setprecision(10)<<fixed<<ans<<endl;
	}
	
	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3248
final_rank: 6

code_snippet: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int NP = 11;
const int pnums[NP] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };

const int MAX_EXP = 50;

/* typedef */

typedef long long ll;

/* global variables */

ll k;

/* subroutines */

double rec(int j, ll n, ll sum) {
  double max_sig = (double)sum / n;
  if (j >= NP) return max_sig;

  ll sum0 = sum;
  
  for (int i = 0; i < MAX_EXP; i++) {
    double sig = rec(j + 1, n, sum0);
    if (max_sig < sig) max_sig = sig;

    n *= pnums[j];
    if (n > k) break;
    sum0 = sum0 * pnums[j] + sum;
  }

  return max_sig;
}

/* main */

int main() {
  for (;;) {
    cin >> k;
    if (k == 0) break;

    double ans = rec(0, 1LL, 1LL);
    printf("%.6lf\n", ans);
  }
  return 0;
}
accuracy: 1
time_ms: 1680
memory_kb: 1180
final_rank: 9

code_snippet: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }


long long power(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

long long n;
long long pr[15] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};

double res = 1.0;
void rec(long long now, int i, int k, double tmp) {
    if (now > n) return;
    chmax(res, tmp);
    
    rec(now * pr[i], i, k+1, tmp * (power(pr[i],k+2) - 1) / (power(pr[i],k+2) - pr[i]) );
    rec(now * pr[i+1], i+1, 1, tmp * (pr[i+1] + 1) / pr[i+1] );
}

int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    while (cin >> n) {
        if (n == 0) break;
        res = 1.0;
        rec(2, 0, 1, 1.5);
        
        cout << fixed << setprecision(9) << res << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 1224
final_rank: 3

code_snippet: #include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;

void primeNumber(int N, vector<bool>& prime)
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int MAX = 500;
vector<int> prime;
map<long long, double> m;

void solve(int i, long long a, long long sum)
{
    m[a] = sum / (double) a;
    map<long long, double>::iterator it = m.find(a);
    while(it != --m.end()){
        map<long long, double>::iterator it2 = it;
        ++ it2;
        if(it2->second < it->second){
            m.erase(it2);
        }else{
            break;
        }
    }
    if(it != m.begin()){
        map<long long, double>::iterator it2 = it;
        -- it2;
        if(it2->second > it->second)
            m.erase(it);
    }

    if(i > prime.size())
        return;

    long long tmp = 1;
    long long sum2 = sum;
    for(;;){
        a *= prime[i];
        if(a > 1000000000000000LL)
            return;

        tmp *= prime[i];
        sum2 += sum * tmp;

        solve(i+1, a, sum2);
    }
}

int main()
{
    vector<bool> isPrime;
    primeNumber(MAX, isPrime);
    for(int i=0; i<=MAX; ++i){
        if(isPrime[i])
            prime.push_back(i);
    }

    solve(0, 1, 1);
    m[LLONG_MAX] = 0.0;

    for(;;){
        long long k;
        cin >> k;
        if(k == 0)
            return 0;

        map<long long, double>::iterator it = m.upper_bound(k);
        -- it;
        printf("%.10f\n", it->second);
    }
}
accuracy: 1
time_ms: 20
memory_kb: 1236
final_rank: 1

code_snippet: #include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;

void primeNumber(int N, vector<bool>& prime)
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int MAX = 500;
vector<int> prime;
map<long long, double> m;

void solve(int i, long long a, long long sum)
{
    if(a > 1000000000000000LL)
        return;

    m[a] = sum / (double) a;
    map<long long, double>::iterator it = m.find(a);
    while(it != --m.end()){
        map<long long, double>::iterator it2 = it;
        ++ it2;
        if(it2->second < it->second){
            m.erase(it2);
        }else{
            break;
        }
    }
    if(it != m.begin()){
        map<long long, double>::iterator it2 = it;
        -- it2;
        if(it2->second > it->second)
            m.erase(it);
    }

    if(i > prime.size())
        return;

    long long tmp = 1;
    long long sum2 = sum;
    for(;;){
        a *= prime[i];
        if(a > 1000000000000000LL)
            return;

        tmp *= prime[i];
        sum2 += sum * tmp;

        solve(i+1, a, sum2);
    }
}

int main()
{
    vector<bool> isPrime;
    primeNumber(MAX, isPrime);
    for(int i=0; i<=MAX; ++i){
        if(isPrime[i])
            prime.push_back(i);
    }

    solve(0, 1, 1);
    m[LLONG_MAX] = 0.0;

    for(;;){
        long long k;
        cin >> k;
        if(k == 0)
            return 0;

        map<long long, double>::iterator it = m.upper_bound(k);
        -- it;
        printf("%.10f\n", it->second);
    }
}
accuracy: 1
time_ms: 20
memory_kb: 1236
final_rank: 1

code_snippet: #include <iostream>
#include <cstdio>
using namespace std;
typedef long long Int;
#define REP(i,n) for(int i=0;i<(int)n;++i)

long long table[] = {
1ll
,2ll
,4ll
,6ll
,12ll
,24ll
,36ll
,48ll
,60ll
,120ll
,180ll
,240ll
,360ll
,720ll
,840ll
,1260ll
,1680ll
,2520ll
,5040ll
,10080ll
,15120ll
,25200ll
,27720ll
,55440ll
,110880ll
,166320ll
,277200ll
,332640ll
,554400ll
,665280ll
,720720ll
,1441440ll
,2162160ll
,3603600ll
,4324320ll
,7207200ll
,8648640ll
,10810800ll
,21621600ll
,36756720ll
,61261200ll
,73513440ll
,122522400ll
,147026880ll
,183783600ll
,367567200ll
,698377680ll
,735134400ll
,1102701600ll
,1163962800ll
,1396755360ll
,2327925600ll
,2793510720ll
,3491888400ll
,6983776800ll
,13967553600ll
,20951330400ll
,27935107200ll
,41902660800ll
,48886437600ll
,80313433200ll
,160626866400ll
,321253732800ll
,481880599200ll
,642507465600ll
,963761198400ll
,1124388064800ll
,1927522396800ll
,2248776129600ll
,3373164194400ll
,4497552259200ll
,4658179125600ll
,6746328388800ll
,9316358251200ll
,13974537376800ll
,18632716502400ll
,27949074753600ll
,32607253879200ll
,55898149507200ll
,65214507758400ll
,97821761637600ll
,130429015516800ll
,144403552893600ll
,195643523275200ll
,288807105787200ll
,433210658680800ll
,577614211574400ll
,866421317361600ll
,1010824870255200ll
,1732842634723200ll
,2021649740510400ll
,3032474610765600ll
,4043299481020800ll
};


long long divisor(long long n){
	long long i = 1 , sum = 0;
	for(; i*i < n ; i++) if(n%i == 0) sum += i + n/i;
	if(i*i == n) sum += i;
	return sum;
}

int main(){
	long long n;
	while(cin >> n && n){
		double mx = 0;
		for(int i = 0 ; i < sizeof(table) / sizeof(table[0]) ; i++){
			if(table[i] <= n)mx = max(mx,1.0*divisor(table[i]) / table[i]);
		}
		printf("%.6lf\n",mx);
	}
}
accuracy: 1
time_ms: 6320
memory_kb: 908
final_rank: 12

code_snippet: #include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int pn(int a[],int n){
  int i,j;
  a[0]=a[1]=0;
  for(i=2;i<n;i++)
    a[i]=i;
  for(i=2;i*i<n;i++){
    if(a[i]){
      for(j=i*i;j<n;j+=i)
        a[j]=0;
    }
  }
  j=2;
  for(i=0;j<n;i++){
    a[i]=a[j];
    for(j++;j<n&&a[j]==0;j++);
  }
  return i;
}
int a[42];
vector<pair<long long,double> > c;
void fn(int p,long long q,long long r){
  c.push_back(make_pair(q,(double)r/q));
  if(p<13){
    long long sm=1,pi=a[p];
    while(a[p]<=1000000000000000ll/q){
      q*=a[p];
      sm+=pi;
      pi*=a[p];
      fn(p+1,q,r*sm);
    }
  }
  return;
}
int main(){
  int i;
  pn(a,42);
  c.reserve(254000);
  fn(0,1,1);
  sort(c.begin(),c.end());
  double mx=0;
  for(i=0;i<(int)c.size();i++){
    if(mx<c[i].second){
      mx=c[i].second;
    }else{
      c[i]=make_pair(0,0);
    }
  }
  c.push_back(make_pair(1000000000000001ll,0));
  remove(c.begin(),c.end(),pair<long long,double>(0,0)),c.end();
  long long n;
  while(cin>>n,n){
    int mn=0,mx=87;
    for(;;){
      if(0){
      }else if(c[(mn+mx)/2].first>n){
	mx=(mn+mx)/2-1;
      }else if(c[(mn+mx)/2+1].first<=n){
	mn=(mn+mx)/2+1;
      }else{
	break;
      }
    }
    printf("%.6lf\n",c[(mn+mx)/2].second);
  }
  return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 4808
final_rank: 11

code_snippet: #include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

typedef long long ll;

const int N=1000000;
double ans;

bool a[N];
int b[N];
int ind;

int generate(){
  for(int i=0;i<N;i++)a[i]=i%2;
  for(int i=3;i*i<=N;i+=2){
    if (a[i])for(int j=2*i;j<N;j+=i)a[j]=false;
  }
  int index=0;
  b[index++]=2;
  for(int i=3;i<N;i+=2){
    if (a[i])b[index++]=i;
  }
  return index;
}

void solve(ll n,int *pri,int now,double val,double sum){
  if (val > n || now == ind)return;
  ans=max(ans,sum/val);
  if (pri[now] > n)return;
  
  ll tmp  =  1;
  ll tsum =  1;
  while(true){
    if (tmp > n)break;
    if (tmp!=1)solve(n,pri,now+1,val*tmp,sum*tsum);
    tmp*=pri[now];
    tsum+=tmp;
  }

}

main(){
  ind=generate();
  ll n;
  while(cin>>n && n){
    ans = 1;
    solve(n,b,0,1,1);
    printf("%.6lf\n",ans);
  }
  return false;
}
accuracy: 1
time_ms: 580
memory_kb: 2188
final_rank: 5

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<climits>
#include<stack>

using namespace std;

#define MAX 10000003
#define KMAX 1000000000000003LL

vector<int> vprimes;
bool *isPrime = new bool[MAX];

void MakePrime(){
  for(int i=0;i<MAX;++i)
    isPrime[i]=true;
  isPrime[0]=false;
  isPrime[1]=false;
  for(long long int i=2;i<MAX;++i)
    if(isPrime[i])
      for(long long int j=2;i*j<MAX;++j)
	isPrime[i*j]=false;
  for(int i = 0; i < MAX; ++i)
    if( isPrime[i] )
      vprimes.push_back( i );
}

template<typename Integer>
void Factorization(Integer n, vector< pair<Integer,Integer> > &vp){
  if(n==1){vp.push_back(make_pair(1,1));return ;}
  for(int i = 0; i < vprimes.size(); ++i){
    while(n%vprimes[i]==0){
      n/=vprimes[i];
      if( vp.size()>0 && vp.back().first == vprimes[i] )
	vp.back().second++;
      else
	vp.push_back( make_pair(vprimes[i],1) );
    }
    if(n==1)return ;
  }
  vp.push_back( make_pair(n,1) );  
}

// ®ªÌñ,vvÉ½¢µÄÐÆÂÌªvª èAvÌ®Íå«¢ÉÀÔ
void partitions(int n, int max_n, vector<int>& v, vector<vector<int> >& vv) {
  if(n==0){vv.push_back(v);return;}
  for(int i=min(n,max_n);i>0;i--){v.push_back(i);partitions(n-i,i,v,vv);v.pop_back();}
}

template<typename Integer>
Integer divisorFunction1(Integer n){
  Integer ret=0;
  if(n==1)return 1;
  stack<pair<Integer,Integer> > st;
  vector< pair<Integer,Integer> > facts;
  Factorization(n,facts);
  st.push(make_pair(0,1));
  while(!st.empty()){
    pair<Integer,Integer> nst=st.top();
    st.pop();
    if(nst.first>=facts.size()){ret+=nst.second;continue;}
    Integer r=1;
    for(int i = 0; i < facts[nst.first].second+1; ++i){
      pair<Integer,Integer> nx(nst.first+1,nst.second*r);
      st.push(nx);
      r*=facts[nst.first].first;
    }
  }
  return ret;
}

int main()
{
  map<long long int, double> M;
  MakePrime();
  for(int base=0;base<2;++base){
    for(int n=1;n<21;++n){
      vector<int> v;
      vector< vector<int> > vv;
      //cerr<<n<<endl;
      partitions(n, 13, v, vv);
      for(int i = 0; i < vv.size(); ++i){
	long long int llv=1;
	for(int j = 0; j < vv[i].size(); ++j){
	  for(int k = 0; k < vv[i][j]; ++k){
	    if(llv*vprimes[base+j]>KMAX)break;
	    llv *= vprimes[base+j];
	  }
	  if(llv*vprimes[base+j]>KMAX)break;
	}
	if(llv>0&&llv<KMAX){
	  long long int df=divisorFunction1(llv);
	  M[llv]=max(M[llv],divisorFunction1(llv)/(double)llv);
	}
      }
    }
  }
  //cout << M.size() << endl;
  map<long long int, double> Mans;
  double maxi=0.0;
  for(map<long long int,double>::iterator itm=M.begin(); itm!=M.end(); ++itm){
    maxi=max(maxi,itm->second);
    Mans[itm->first]=maxi;
  }
  while(true){
    long long int k;
    double ans=1;
    cin >> k;
    if(k==0)break;
    map<long long int, double>::iterator itm = Mans.lower_bound(k);
    if( itm->first > k )--itm;
    ans = max(ans,itm->second);
    printf("%.6lf\n",ans);
  }
  return 0;
}
accuracy: 1
time_ms: 1390
memory_kb: 13000
final_rank: 13

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<climits>
#include<stack>

using namespace std;

#define MAX 10000003
#define KMAX 1000000000000003LL

vector<int> vprimes;
bool *isPrime = new bool[MAX];

template<typename Integer>
Integer GCD(Integer a, Integer b){
  if(!b)return a;
  else return GCD(b,a%b);
}

void MakePrime(){
  for(int i=0;i<MAX;++i)
    isPrime[i]=true;
  isPrime[0]=false;
  isPrime[1]=false;
  for(long long int i=2;i<MAX;++i)
    if(isPrime[i])
      for(long long int j=2;i*j<MAX;++j)
	isPrime[i*j]=false;
  for(int i = 0; i < MAX; ++i)
    if( isPrime[i] )
      vprimes.push_back( i );
}

template<typename Integer>
void Factorization(Integer n, vector<Integer> &vp){
  if(n==1){vp.push_back(1);return ;}
  for(int i = 0; i < vprimes.size(); ++i){
    while(n%vprimes[i]==0){
      n/=vprimes[i];
      vp.push_back( vprimes[i] );
    }
    if(n==1)break;
  }
  if(n!=1)vp.push_back(n);
}

template<typename Integer>
void Factorization(Integer n, vector< pair<Integer,Integer> > &vp){
  if(n==1){vp.push_back(make_pair(1,1));return ;}
  for(int i = 0; i < vprimes.size(); ++i){
    while(n%vprimes[i]==0){
      n/=vprimes[i];
      if( vp.size()>0 && vp.back().first == vprimes[i] )
	vp.back().second++;
      else
	vp.push_back( make_pair(vprimes[i],1) );
    }
    if(n==1)return ;
  }
  vp.push_back( make_pair(n,1) );  
}

/* Euler phi */
template<typename Integer>
Integer EulerPhi(Integer n){
  if(n==0)return 0;
  Integer ret=n;
  for(Integer x=2;x*x<=n;++x){
    if(!(n%x)){
      ret-=ret/x;
      while(!(n%x))n/=x;
    }
  }
  if(n>1)ret-=ret/n;
  return ret-1;
}

// ®ªÌñ,vvÉ½¢µÄÐÆÂÌªvª èAvÌ®Íå«¢ÉÀÔ
void partitions(int n, int max_n, vector<int>& v, vector<vector<int> >& vv) {
  if(n==0){vv.push_back(v);return;}
  for(int i=min(n,max_n);i>0;i--){v.push_back(i);partitions(n-i,i,v,vv);v.pop_back();}
}

// ®ªÌ ( O(nm) ) n ð mÂÈºÌ®Åª·é
long long int partitions_num(int n, int m){
  long long int dp[m+1][n+1];
  dp[0][0]=1;
  for(int i = 1; i <= m; ++i){
    for(int j = 0; j <= n; ++j){
      dp[i][j]=dp[i][j-i];
      if(j-i>=0)
	dp[i][j]+=dp[i-1][j];
    }
  }
  return dp[m][n];
}

// d¡gÝí¹ O(nm) a[i]Â éníÞÌàÌ©çvmÉÈéæ¤ÉIñ¾Æ«ÌgÝí¹Ì
long long int dupl_comb(int n, int m, int a[]){
  long long int dp[n+1][m+1];
  for(int i = 0; i <= n; ++i){
    dp[i][0]=1;
  }
  for(int i = 0; i <= n; ++i){
    for(int j = 1; j <= m; ++j){
      dp[i+1][j]=dp[i+1][j-1]+dp[i][j];
      if(j-1-a[i]>=0)
	dp[i+1][j]+=dp[i][j-1-a[i]];
    }
  }
  return dp[n][m];
}

template<typename Integer>
Integer divisorFunction1(Integer n){
  Integer ret=0;
  if(n==1)return 1;
  stack<pair<Integer,Integer> > st;
  vector< pair<Integer,Integer> > facts;
  Factorization(n,facts);
  st.push(make_pair(0,1));
  while(!st.empty()){
    pair<Integer,Integer> nst=st.top();
    st.pop();
    if(nst.first>=facts.size()){ret+=nst.second;continue;}
    Integer r=1;
    for(int i = 0; i < facts[nst.first].second+1; ++i){
      pair<Integer,Integer> nx(nst.first+1,nst.second*r);
      st.push(nx);
      r*=facts[nst.first].first;
    }
  }
  return ret;
}

static double memo[MAX]={0,};
static int memo_n[MAX]={0,};
int main2(){
  MakePrime();
  map<long long int,double> M;
  long long int k=1;
  while(true){
    long long int ans_n = -1;
    double ans = -1;
    //cin >> k;
    if(k%10000==0){
      cout << k << ' ' << M.size() << endl;
    }
    if( k > 1000000 ) break;
    for(long long int n = k; n >= 1; --n){
      if(memo[n]>0){
	if(memo[n]>ans){
	  ans=memo[n];
	  ans_n=memo_n[n];
	}
	break;
      }
      long long int sigma = divisorFunction1(n);
      if(ans<(double)sigma / (double)n ){
	ans=(double)sigma / (double)n;
	ans_n = n;
      }
    }
    memo[k]=ans;
    memo_n[k]=ans_n;
    M[ans_n]=ans;
    //    cout << k << ' ' << ans_n << ' ' << ans << endl;
    ++k;
  }
  for(map<long long int,double>::iterator itm = M.begin(); itm != M.end(); ++itm){
    vector< pair<long long int, long long int> > facts;
    Factorization(itm->first, facts);
    cout << itm->first << ' ' << itm->second << endl;
    for(int i = 0; i < facts.size(); ++i){
      cout << facts[i].first << "(" << facts[i].second << ") ";
    }
    cout << endl;
  }
  cout << endl;
  return 0;
}

int main()
{
  map<long long int, double> M;
  MakePrime();
  for(int base=0;base<2;++base){
    for(int n=1;n<21;++n){
      vector<int> v;
      vector< vector<int> > vv;
      cerr<<n<<endl;
      partitions(n, 14, v, vv);
      for(int i = 0; i < vv.size(); ++i){
	long long int llv=1;
	for(int j = 0; j < vv[i].size(); ++j){
	  for(int k = 0; k < vv[i][j]; ++k){
	    if(llv*vprimes[base+j]>KMAX)break;
	    llv *= vprimes[base+j];
	  }
	  if(llv*vprimes[base+j]>KMAX)break;
	}
	if(llv>0&&llv<KMAX){
	  long long int df=divisorFunction1(llv);
	  M[llv]=max(M[llv],divisorFunction1(llv)/(double)llv);
	}
      }
    }
  }
  while(true){
    long long int k;
    double ans=1;
    cin >> k;
    if(k==0)break;
    if(k==1)ans=1;
    for(map<long long int,double>::iterator itm=M.begin(); itm!=M.end(); ++itm){
      if(itm->first<=k){
	ans=max(ans,itm->second);
      }else break;
    }
    printf("%.6lf\n",ans);
  }
  /*

  MakePrime();
  for(long long int div=1;div<30;++div){
    vector< pair<long long int,long long int> > facts;
    long long int prime=0;
    long long int v=1;
    Factorization(div,facts);
    for(int i = (int)facts.size()-1; i >= 0; --i){
      for(int k = 0; k < facts[i].second; ++k){
	for(int l = 0; l < facts[i].first-1; ++l){
	  v*=vprimes[prime];
	}
	++prime;
      }
    }
    if(v<0||v>KMAX)continue;
    else{
      cout << div << ' ' << v << ' ' << divisorFunction1(v) << endl;
    }
  }
  */
  /*
  MakePrime();
  map<long long int, double> M;
  stack<pair<int,long long int> > st;
  st.push(make_pair(0,2));
  while(!st.empty()){
    pair<int,long long int> now=st.top();st.pop();
    divisorFunction1(now.second)/(double)now.second;
    //cout << now.first << ' ' << now.second << endl;
    long long int r=vprimes[now.first];
    for(int i = 0; ; ++i){
      //cout << now.second * r << endl;
      if(now.second*r>KMAX||now.second*r<now.second)break;
      st.push(make_pair(now.first+1,now.second*r));
      r *= vprimes[now.first];
    }
  }

  while(true){
    int k ;
    cin >> k ;
    if( k == 0 ) break ;
    
  }
  */
  return 0;
}
accuracy: 1
time_ms: 6100
memory_kb: 13000
final_rank: 14