錯誤: 找不到或無法載入主要類別 base_java Killed
import java.util.*;
public class ZeroJudge_8 {
static int count=0;
static int c=0;
static int f=0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int A=sc.nextInt();
KK(A);
}
static void KK(int A){
int b=0;
int [] nums = new int [A];
int d=0;
for(int a = 2 ; a<=A ; a++){
if(a%2!=0){
for(int k = 2 ; k<=Math.sqrt(a) ; k++){
b = a%k==0 ? 1 : 0 ;
if(b==1){
k=a/2;
}
}
}
if(b!=1){
if(A%a==0){
//System.out.print("\n"+a+"\n");
nums[d++]=a;
}
}
b=0;
}
for(int a = 0 ; a<nums.length ; a++){
if(nums[a]!=0){
f=nums[a+1]==0 ? 1 : 0;
c=nums[a];
KK1(A);
}
else break;
}
}
static void KK1(int A){
if(A%c==0){
count++;
KK1(A/c);
}
if (A%c!=0){
if(count<=1){
if(f==0){
System.out.print(c+" * ");
}
else System.out.print(c);
count=0;
}
else{
if(f==0){
System.out.print(c+"^"+count+" * ");
count=0;
}
else System.out.print(c);
}
}
}
}
#2: 6% TLE (3s)
錯誤: 找不到或無法載入主要類別 base_java Killed
import java.util.*;
public class ZeroJudge_8 {
static int count=0;
static int c=0;
static int f=0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int A=sc.nextInt();
KK(A);
}
static void KK(int A){
int b=0;
int [] nums = new int [A];
int d=0;
for(int a = 2 ; a<=A ; a++){
if(a%2!=0){
for(int k = 2 ; k<=Math.sqrt(a) ; k++){
b = a%k==0 ? 1 : 0 ;
if(b==1){
k=a/2;
}
}
}
if(b!=1){
if(A%a==0){
//System.out.print("\n"+a+"\n");
nums[d++]=a;
}
}
b=0;
}
for(int a = 0 ; a
if(nums[a]!=0){
f=nums[a+1]==0 ? 1 : 0;
c=nums[a];
KK1(A);
}
else break;
}
}
static void KK1(int A){
if(A%c==0){
count++;
KK1(A/c);
}
if (A%c!=0){
if(count<=1){
if(f==0){
System.out.print(c+" * ");
}
else System.out.print(c);
count=0;
}
else{
if(f==0){
System.out.print(c+"^"+count+" * ");
count=0;
}
else System.out.print(c);
}
}
}
}
建議找到因數後就把A除以因數