結果
| 問題 |
No.500 階乗電卓
|
| コンテスト | |
| ユーザー |
uafr_cs
|
| 提出日時 | 2017-04-07 22:37:09 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 957 bytes |
| コンパイル時間 | 1,925 ms |
| コンパイル使用メモリ | 76,516 KB |
| 実行使用メモリ | 54,344 KB |
| 最終ジャッジ日時 | 2024-07-16 01:11:53 |
| 合計ジャッジ時間 | 5,537 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 13 |
ソースコード
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 <= Math.min(N, 120); 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;
}
}
final BigInteger mod = value.mod(BigInteger.valueOf(MOD));
System.out.println(mod.equals(BigInteger.ZERO) ? "0" : mod.toString());
}
}
uafr_cs