結果
問題 | No.502 階乗を計算するだけ |
ユーザー |
|
提出日時 | 2024-10-14 22:58:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 529 ms / 1,000 ms |
コード長 | 753 bytes |
コンパイル時間 | 1,588 ms |
コンパイル使用メモリ | 167,636 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-14 22:58:43 |
合計ジャッジ時間 | 6,077 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 |
ソースコード
#include <bits/stdc++.h>using namespace std;// clang-format offstruct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;// clang-format on#define int long longconst int MOD = 1000000007;const int MODSplit = 100000000;signed main() {int N;cin >> N;if (N >= MOD){cout << 0 << '\n';} else {vector<int> A_list = {1,927880474,933245637,668123525,429277690,733333339,724464507,957939114,203191898,586445753,698611116};int tmp = A_list[N / MODSplit];if (N % MODSplit != 0){int start = N - (N % MODSplit) + 1;for (int i = start; i <= N; i++) {tmp = (tmp * i) % MOD;}}cout << tmp << '\n';}}