結果

問題 No.500 階乗電卓
ユーザー mmn15277198mmn15277198
提出日時 2021-04-11 18:50:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 734 bytes
コンパイル時間 703 ms
コンパイル使用メモリ 86,688 KB
実行使用メモリ 5,188 KB
最終ジャッジ日時 2023-09-09 20:59:07
合計ジャッジ時間 1,830 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,708 KB
testcase_01 AC 3 ms
4,960 KB
testcase_02 AC 3 ms
4,564 KB
testcase_03 AC 3 ms
4,644 KB
testcase_04 AC 3 ms
4,608 KB
testcase_05 AC 3 ms
4,636 KB
testcase_06 AC 3 ms
4,588 KB
testcase_07 AC 3 ms
5,016 KB
testcase_08 AC 3 ms
4,612 KB
testcase_09 AC 3 ms
4,620 KB
testcase_10 AC 3 ms
4,636 KB
testcase_11 AC 3 ms
4,700 KB
testcase_12 AC 3 ms
4,616 KB
testcase_13 AC 2 ms
5,188 KB
testcase_14 AC 4 ms
4,576 KB
testcase_15 AC 3 ms
4,644 KB
testcase_16 AC 3 ms
4,608 KB
testcase_17 AC 3 ms
4,712 KB
testcase_18 AC 3 ms
4,756 KB
testcase_19 AC 3 ms
4,640 KB
testcase_20 AC 3 ms
5,028 KB
testcase_21 AC 3 ms
4,592 KB
testcase_22 AC 3 ms
4,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    long long n;
    cin >> n;
    vector<long long> fact(220000 , 0);
    fact[0] = 1;
    for (int i = 1; i < 60; i++) {
        long long now = i * fact[i - 1] % 10000000000000;
        fact[i] = now;
    }
    if (n >= 50) {
        cout << "000000000000" << endl;
    } else {
        string s = to_string(fact[n]);
        if (s.size() == 13) {
            for (int i = 1; i < 13; i++) {
                cout << s[i];
            }
            cout << endl;
        } else {
            cout << s << endl;
        }
    }
    return 0;
}




0