結果

問題 No.500 階乗電卓
ユーザー uafr_csuafr_cs
提出日時 2017-04-07 22:30:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 767 bytes
コンパイル時間 2,066 ms
コンパイル使用メモリ 73,236 KB
実行使用メモリ 56,400 KB
最終ジャッジ日時 2023-09-23 00:23:20
合計ジャッジ時間 6,100 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,048 KB
testcase_01 AC 123 ms
55,868 KB
testcase_02 AC 126 ms
55,804 KB
testcase_03 AC 126 ms
55,808 KB
testcase_04 AC 124 ms
56,216 KB
testcase_05 AC 125 ms
55,948 KB
testcase_06 AC 127 ms
55,880 KB
testcase_07 AC 126 ms
55,664 KB
testcase_08 AC 126 ms
55,860 KB
testcase_09 AC 127 ms
55,716 KB
testcase_10 AC 125 ms
55,564 KB
testcase_11 AC 124 ms
56,184 KB
testcase_12 AC 127 ms
55,616 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 125 ms
55,868 KB
testcase_16 AC 126 ms
56,044 KB
testcase_17 AC 124 ms
56,080 KB
testcase_18 AC 126 ms
56,400 KB
testcase_19 AC 129 ms
55,820 KB
testcase_20 AC 125 ms
53,824 KB
testcase_21 AC 125 ms
56,064 KB
testcase_22 AC 124 ms
55,988 KB
権限があれば一括ダウンロードができます

ソースコード

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.nextLong();
		
		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