結果
問題 | No.500 階乗電卓 |
ユーザー | shinwisteria |
提出日時 | 2017-04-08 10:44:49 |
言語 | Java19 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 562 bytes |
コンパイル時間 | 3,363 ms |
コンパイル使用メモリ | 72,220 KB |
実行使用メモリ | 58,320 KB |
最終ジャッジ日時 | 2023-09-24 23:16:50 |
合計ジャッジ時間 | 7,266 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 124 ms
55,836 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 121 ms
55,764 KB |
testcase_12 | AC | 124 ms
55,852 KB |
testcase_13 | AC | 124 ms
55,924 KB |
testcase_14 | AC | 125 ms
56,016 KB |
testcase_15 | AC | 124 ms
55,988 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
ソースコード
import java.util.Scanner; public class Kaijocalc { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner s = new Scanner(System.in); long N = s.nextLong(); long ans = 1; StringBuilder str = new StringBuilder(); s.close(); long t = (long)Math.pow(10, 12); for(int i = 1;i <= N;i++){ ans *= i; if(ans > t){ str.append(ans); str.delete(0, str.length()-12); ans %= t; } if(ans == 0){ str = new StringBuilder("0"); break; } } System.out.println(str); } }