結果

問題 No.500 階乗電卓
ユーザー uafr_csuafr_cs
提出日時 2017-04-07 22:33:40
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 914 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 72,956 KB
実行使用メモリ 58,296 KB
最終ジャッジ日時 2023-09-23 00:31:35
合計ジャッジ時間 6,045 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 125 ms
55,864 KB
testcase_05 AC 126 ms
56,172 KB
testcase_06 AC 123 ms
56,152 KB
testcase_07 AC 122 ms
56,020 KB
testcase_08 AC 124 ms
55,752 KB
testcase_09 AC 127 ms
55,812 KB
testcase_10 AC 126 ms
56,080 KB
testcase_11 AC 124 ms
56,252 KB
testcase_12 AC 124 ms
56,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 125 ms
56,084 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

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));
			//System.out.println(next_value);
			
			final BigInteger value_mod = value.mod(BigInteger.valueOf(MOD));
			final BigInteger next_mod  = next_value.mod(BigInteger.valueOf(MOD));
			
			if(value_mod.equals(next_mod)){
				break;
			}else{
				value = next_value;
			}
		}
		
		System.out.println(value.equals(BigInteger.ZERO) ? "000000000000" : value.mod(BigInteger.valueOf(MOD)));
	}
}
0