Acdream 1667 idol 2 (ACdreamer java session)

Source: Internet
Author: User

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 ;}}}}}
 


 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.