結果

問題 No.500 階乗電卓
ユーザー zimphazimpha
提出日時 2017-04-08 02:26:24
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,075 bytes
コンパイル時間 2,322 ms
コンパイル使用メモリ 74,640 KB
実行使用メモリ 39,868 KB
最終ジャッジ日時 2023-09-23 03:36:36
合計ジャッジ時間 4,827 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 42 ms
33,476 KB
testcase_05 AC 42 ms
33,456 KB
testcase_06 AC 139 ms
39,748 KB
testcase_07 AC 41 ms
33,416 KB
testcase_08 AC 44 ms
33,516 KB
testcase_09 AC 43 ms
33,376 KB
testcase_10 AC 41 ms
33,512 KB
testcase_11 AC 116 ms
39,136 KB
testcase_12 AC 114 ms
39,016 KB
testcase_13 AC 114 ms
39,200 KB
testcase_14 AC 117 ms
39,868 KB
testcase_15 AC 116 ms
39,116 KB
testcase_16 AC 116 ms
39,248 KB
testcase_17 AC 117 ms
38,936 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Chiaki.Hoshinomori
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task500 solver = new Task500();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task500 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long mod = 1000000000000l;
            long r = 1;
            if (n > 100) {
                out.println(0);
            } else {
                for (long i = 0; i < n; i++) {
                    r = r * (i + 1) % mod;
                }
                if (n <= 14) {
                    out.println(r);
                } else {
                    out.printf("%012d\n", r);
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

0