标签:des style blog class code java
Time Limit: 2000/1000 MS
(Java/Others) Memory Limit: 65768/65768 K
(Java/Others)
Total Submission(s): 1561 Accepted
Submission(s): 680
1 import java.io.*; 2 import java.awt.*; 3 import java.math.BigInteger; 4 import java.util.Scanner; 5 6 public class Main { 7 8 static int prime[] = new int [1002]; 9 static int len = 0; 10 static BigInteger dp[] = new BigInteger[1002]; 11 public static void main(String[] args) { 12 fun(); 13 int T=0; 14 Scanner cin = new Scanner(System.in); 15 T=cin.nextInt(); 16 while(T>0) 17 { 18 BigInteger n = cin.nextBigInteger(); 19 int x=0; 20 for(int i=1;i<=len;i++) 21 { 22 if(n.compareTo(dp[i])<0) 23 { 24 x=i-1; 25 break; 26 } 27 } 28 System.out.println(dp[x]); 29 T--; 30 } 31 } 32 static void fun(){ 33 boolean s[] = new boolean[1007]; 34 for(int i=0;i<s.length;i++){ 35 s[i]=false; 36 } 37 for(int i=0;i<dp.length;i++){ 38 dp[i]=BigInteger.ZERO; 39 } 40 for(int i=2;i<1007;i++) 41 { 42 if(s[i]==true) continue; 43 prime[++len]=i; 44 for(int j=i*2;j<1007;j=j+i) 45 s[j]=true; 46 } 47 dp[0] = BigInteger.ONE; 48 for(int i=1;i<=len;i++) 49 { 50 dp[i] = dp[i-1].multiply(BigInteger.valueOf(prime[i])); 51 } 52 } 53 }
hdu 4002 Find the maximum,布布扣,bubuko.com
标签:des style blog class code java
原文地址:http://www.cnblogs.com/tom987690183/p/3714999.html