結果

問題 No.500 階乗電卓
ユーザー akitsu818
提出日時 2017-04-30 22:45:17
言語 Java
(openjdk 23)
結果
MLE  
実行時間 -
コード長 581 bytes
コンパイル時間 2,281 ms
コンパイル使用メモリ 74,552 KB
実行使用メモリ 839,320 KB
最終ジャッジ日時 2024-09-14 00:00:29
合計ジャッジ時間 7,221 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other MLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

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