boss_luke @ 2023-09-18 22:39:10
public class P1009 {
public static void main(String[] args) {
// TODO 自动生成的方法存根
Scanner sc = new Scanner(System.in);
int number = sc.nextInt();
String result = "1";
for(int m = 2 ; m <= number; m++) {
String num1 = Integer.toString(m);
result = multiply(result,num1);
}
System.out.print(result);
}
public static String multiply(String num1, String num2) {
int len1 = num1.length();
int len2 = num2.length();
int[] result = new int[len1 + len2];
for (int i = len1 - 1; i >= 0; i--) {
int digit1 = num1.charAt(i) - '0';
for (int j = len2 - 1; j >= 0; j--) {
int digit2 = num2.charAt(j) - '0';
int product = digit1 * digit2;
int pos1 = i + j;
int pos2 = i + j + 1;
int sum = product + result[pos2];
result[pos1] += sum / 10;
result[pos2] = sum % 10;
}
}
StringBuilder sb = new StringBuilder();
for (int digit : result) {
if (!(sb.length() == 0 && digit == 0)) {
sb.append(digit);
}
}
return sb.length() == 0 ? "0" : sb.toString();
}}
by boss_luke @ 2023-09-18 22:39:43
大神帮我看看我测了本地没问题啊呜呜