結果

問題 No.500 階乗電卓
ユーザー akitsu818akitsu818
提出日時 2017-04-30 22:49:51
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 615 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 72,464 KB
実行使用メモリ 803,612 KB
最終ジャッジ日時 2023-10-12 00:02:13
合計ジャッジ時間 16,038 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 MLE -
testcase_04 AC 129 ms
55,380 KB
testcase_05 AC 130 ms
55,592 KB
testcase_06 AC 1,244 ms
55,772 KB
testcase_07 AC 128 ms
55,368 KB
testcase_08 AC 126 ms
55,708 KB
testcase_09 AC 126 ms
53,708 KB
testcase_10 AC 129 ms
55,880 KB
testcase_11 AC 134 ms
55,560 KB
testcase_12 AC 139 ms
55,820 KB
testcase_13 AC 201 ms
55,508 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	static boolean isbig = false;
	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);
		long N = cin.nextLong();
		long tmp = 0L;
		int sub=0;
		cin.close();
		tmp = func(N);
		if(isbig&&String.valueOf(tmp).length()<12){
			sub = 12-String.valueOf(tmp).length();
			for(int i =0;i<sub;i++){
			System.out.print("0");
			}
		}
		System.out.println(tmp);
	}

	static long func(long n){
		if(n==0L){
			return 1;
		}else{
			if((long)Math.pow(10, 12)<n*func(n-1)){
				isbig = true;
			}
			return (n*func(n-1))%(long)Math.pow(10, 12);
		}
	}
}
0