"Topic link": Click here~~
"To the effect of the topic":
Given an integer n, a number x,x between 1 and N, and x/φ (x) is the largest (where φ (x) is the Euler function of x).
"Ideas":
The Euler function is an integrable function, namely: ifThen there are:
and:
Then there are:
To make F (x) the largest, the x must contain as many different prime factors as possible.
Code:
/* * problem:hdu no.4002* Running time:1700ms * Complier:java * Author:javaherongwei * Create time:0:08 Wednesday, 2015/9/23 */import java.util.*;import java.io.*;import java.math.*;import java.math.biginteger;p Ublic class Main{public static void Main (String args[]) {Scanner cin = new Scanner (new Bufferedinputstream (system.in)); fin Al int n=100005;boolean[] ok=new boolean[n];int [] prime= new int [N];int cnt=0; BigInteger [] fac= new BigInteger [65];for (int i=0; i<n; ++i) Ok[i]=false; Linear sieve method for (int i=2; i<n; ++i) {if (!ok[i]) prime[cnt++]=i;for (int j=0; j<cnt&&i*prime[j]<n; ++j) {ok[i* prime[j]]= true;if (i%prime[j]==0) break;}} fac[0]=biginteger.one;for (int i=1; i<=60; ++i) {fac[i]=fac[i-1].multiply (biginteger.valueof (prime[i-1]));} BigInteger n;int T;t=cin.nextint (), while (t-->0) {N=cin.nextbiginteger (), for (int i=1; i<=60; ++i) {if (fac[i+1] . CompareTo (n) >0) {System.out.println (fac[i]); break;}}}}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU 4002 Find The maximum (the properties of Euler function-integrable function (the second problem of the network competition of Dalian 2011)