Dzień dobry, robiłem zadanie Kartkówka z silnią i zerami. W kompilatorze wszystko dobrze działa, ale po podesłaniu rozwiązania wyrzuca "Błąd wykonania (NZEC).
Kod poniżej:
java.io.*;
public class Main {
static int sil(int n){
int j = n;
for (; n>1; n--) {
j = j * (n-1);
}
return j;
}
public static void main(String args[]) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int t, s;
String tt, ss;
tt = in.readLine();
t = Integer.parseInt(tt);
int y = t;
int tab[] = new int[t];
for (; t>0; t--){
ss = in.readLine();
s = Integer.parseInt(ss);
tab[t-1] = sil(s);
}
int m = 1, x;
for (; y>0; y--) {
m = 1;
do {
m = m * 10;
x = tab[y-1] % m;
} while (x == 0);
int i = 0;
for (; m>1; i++){
m = m /10;
}
int g = i-1;
System.out.println(g);
}
}
}