#8456: 判斷質數一直RE (JAVA)


Relax19941007 (XGOMX)


RE (SIGKILL)
執行時期錯誤

產生立即終止訊號!!  Killed
 import java.util.Scanner; public class JAVA {
     public static void main(String[] args) {
         Scanner IN = new Scanner(System.in);
         int a = 1, c = 0;
         while (true) {
             int b = IN.nextInt();
             while (a <= b) {
                 if (b % a == 0) {
                     c = c + 1;
                 }
                 a = a + 1;
             }
             if (c == 2) {
                 System.out.println("質數");
             } else {
                 System.out.println("非質數");
             }
         }
     }
 } 
 我用netbeans都可以執行
判斷是否為質數也沒有問題 
為何他會說我執行時期錯誤?? 
#8459: Re:判斷質數一直RE (JAVA)


tomoyaken14 (歐練)


RE (SIGKILL)
執行時期錯誤

產生立即終止訊號!!  Killed
 import java.util.Scanner; public class JAVA {
     public static void main(String[] args) {
         Scanner IN = new Scanner(System.in);
         int a = 1, c = 0;
         while (true) {
             int b = IN.nextInt();
             while (a <= b) {
                 if (b % a == 0) {
                     c = c + 1;
                 }
                 a = a + 1;
             }
             if (c == 2) {
                 System.out.println("質數");
             } else {
                 System.out.println("非質數");
             }
         }
     }
 } 
 我用netbeans都可以執行
判斷是否為質數也沒有問題 
為何他會說我執行時期錯誤?? 
其實是TLE了(逃~