結果
| 問題 | No.502 階乗を計算するだけ |
| コンテスト | |
| ユーザー |
tonegawa
|
| 提出日時 | 2020-09-15 08:28:06 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,114 bytes |
| コンパイル時間 | 4,595 ms |
| コンパイル使用メモリ | 145,060 KB |
| 最終ジャッジ日時 | 2025-01-14 14:57:01 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 51 TLE * 1 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
#define P 1000000007
int main(){
vll t{1,
927880474,
933245637,
668123525,
429277690,
733333339,
724464507,
957939114,
203191898,
586445753,
698611116};
ll n;std::cin >> n;
if(n==0) std::cout << 1 << '\n';
else if(n>=P) std::cout << 0 << '\n';
else{
ll ret = t[(n / 100000000)];
ll st = (n/100000000) * 100000000;
for(ll i=st+1;i<=n;i++){
ret = (ret * i)%P;
}
std::cout << ret << '\n';
}
}
tonegawa