Acdream 1667 idol 2 (ACdreamer java session)
[General idea ]:
Problem Description
Another idol of Shuyi is Euler! Likewise, there are a lot of Euler's theorem and the well-known Euler's functions.
The Euler's function phi (x) indicates the number of the numbers of integers that are not greater than x and x. Do you want to know the minimum x of phi (x)/x in an integer not greater than n?
Input Multiple groups of data, each group of data has only one integer n, n no more than 100 characters Output an integer x, if there are multiple phi (x)/x equal x, output the smallest x. Sample Input
123
Sample Output
122
[Idea] This question is the same as HDU 4002, the product of the preprocessing prime factor.
Code:
/** This code is made by herongwei * Problem: 1670 * Verdict: Accepted * Submission Date: 22:47:57 * Time: 172 MS * Memory: 26376KB * // package ac0901; import java. io. *; import java. util. *; import java. math. bigInteger; // declare the BigInteger big data class import java. lang. *; public class Main {public static void main (String args []) {using cin = new using (new BufferedInputStream (System. in); final 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
0) while (cin. hasNext () {n = cin. nextBigInteger (); for (int I = 1; I <= 60; ++ I) {if (fac [I]. compareTo (n)> 0) {System. out. println (fac [I-1]); break ;}}}}}