java的水题,特判啊。。。依旧无法1Y。
1 import java.util.*; 2 import java.math.*; 3 4 public class Main { 5 public static void main(String[] args) { 6 Scanner cin = new Scanner(System.in); 7 int prim[] = new int[100]; 8 int i,j,n,num; 9 num = 0; 10 BigInteger ans,temp,t; 11 for(i = 2;;i ++) 12 { 13 for(j = 2;j < i;j ++) 14 { 15 if(i%j == 0) 16 break; 17 } 18 if(j == i) 19 prim[num++] = j; 20 if(num == 50) break; 21 } 22 n = cin.nextInt(); 23 if(n == 2) 24 { 25 System.out.println("-1"); 26 return ; 27 } 28 ans = BigInteger.valueOf(1); 29 for(i = 0;i < n;i ++) 30 { 31 temp = BigInteger.valueOf(prim[i]); 32 ans = ans.multiply(temp); 33 } 34 for(i = 0;i < n;i ++) 35 { 36 t = BigInteger.valueOf(prim[i]); 37 temp = ans.divide(t); 38 System.out.println(temp); 39 } 40 } 41 }