結果

問題 No.500 階乗電卓
ユーザー akitsu818akitsu818
提出日時 2017-04-30 22:45:17
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 581 bytes
コンパイル時間 3,553 ms
コンパイル使用メモリ 71,856 KB
実行使用メモリ 852,652 KB
最終ジャッジ日時 2023-10-12 00:01:24
合計ジャッジ時間 18,554 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 MLE -
testcase_04 AC 122 ms
55,916 KB
testcase_05 AC 126 ms
56,000 KB
testcase_06 TLE -
testcase_07 AC 126 ms
56,172 KB
testcase_08 AC 124 ms
55,688 KB
testcase_09 AC 124 ms
55,780 KB
testcase_10 AC 127 ms
55,684 KB
testcase_11 AC 137 ms
55,708 KB
testcase_12 AC 138 ms
55,944 KB
testcase_13 AC 269 ms
55,940 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){
			sub = 12-String.valueOf(tmp).length();
		for(int i =0;i<sub;i++){
			System.out.print("0");
		}}
		System.out.println(func(N));
	}

	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