結果

問題 No.500 階乗電卓
ユーザー uafr_csuafr_cs
提出日時 2017-04-07 22:29:11
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 766 bytes
コンパイル時間 2,191 ms
コンパイル使用メモリ 79,120 KB
実行使用メモリ 54,416 KB
最終ジャッジ日時 2024-07-16 00:55:26
合計ジャッジ時間 5,642 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 110 ms
39,808 KB
testcase_05 AC 115 ms
40,300 KB
testcase_06 AC 125 ms
41,460 KB
testcase_07 AC 111 ms
40,384 KB
testcase_08 AC 123 ms
41,136 KB
testcase_09 AC 118 ms
41,124 KB
testcase_10 AC 122 ms
41,312 KB
testcase_11 AC 119 ms
41,548 KB
testcase_12 AC 111 ms
40,172 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 122 ms
41,368 KB
testcase_16 AC 123 ms
41,388 KB
testcase_17 AC 120 ms
41,460 KB
testcase_18 AC 125 ms
41,296 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static final long MOD = 1000000000000l;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final long N = sc.nextInt();
		
		BigInteger value = BigInteger.ONE;
		for(long i = 2; i <= N; i++){
			final BigInteger next_value = value.multiply(BigInteger.valueOf(i)).mod(BigInteger.valueOf(MOD));
			//System.out.println(next_value);
			
			if(value.equals(next_value)){
				break;
			}else{
				value = next_value;
			}
		}
		
		System.out.println(value.equals(BigInteger.ZERO) ? "000000000000" : value);
	}
}
0