結果
問題 | No.500 階乗電卓 |
ユーザー | akitsu818 |
提出日時 | 2017-04-30 22:56:36 |
言語 | Java19 (openjdk 21) |
結果 |
MLE
|
実行時間 | - |
コード長 | 610 bytes |
コンパイル時間 | 2,157 ms |
コンパイル使用メモリ | 71,928 KB |
実行使用メモリ | 804,680 KB |
最終ジャッジ日時 | 2023-10-12 00:02:35 |
合計ジャッジ時間 | 16,181 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | MLE | - |
testcase_01 | MLE | - |
testcase_02 | MLE | - |
testcase_03 | MLE | - |
testcase_04 | AC | 126 ms
55,672 KB |
testcase_05 | AC | 127 ms
55,936 KB |
testcase_06 | AC | 1,245 ms
55,564 KB |
testcase_07 | AC | 126 ms
56,316 KB |
testcase_08 | AC | 126 ms
55,608 KB |
testcase_09 | AC | 126 ms
55,788 KB |
testcase_10 | AC | 130 ms
55,940 KB |
testcase_11 | AC | 132 ms
55,488 KB |
testcase_12 | AC | 135 ms
55,852 KB |
testcase_13 | AC | 199 ms
56,052 KB |
testcase_14 | TLE | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
ソースコード
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&&tmp<(long)Math.pow(10, 12)){ sub = 12-String.valueOf(tmp).length(); for(int i =0;i<sub;i++){ System.out.print("0"); } } System.out.println(tmp); } 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); } } }