----------------------------------------------
这道题有坑,虽然明确说<1000,但是实际上是<=1000。
AC代码:
1 import java.util.Scanner; 2 3 public class Main { 4 5 public static void main(String[] args) { 6 7 preprocess(); 8 9 Scanner sc=new Scanner(System.in);10 11 int times=sc.nextInt();12 while(times-->0){13 int n=sc.nextInt();14 int ans=0;15 while(n-->0){16 int t=sc.nextInt();17 if(prime[t]) ans+=t;18 }19 System.out.println(ans);20 }21 }22 23 private static boolean prime[]=new boolean[1001];24 25 public static void preprocess(){26 for(int i=2;i
题目来源: