結果
問題 | No.500 階乗電卓 |
ユーザー |
|
提出日時 | 2018-09-04 01:13:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,059 bytes |
コンパイル時間 | 742 ms |
コンパイル使用メモリ | 94,748 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-10 05:29:30 |
合計ジャッジ時間 | 1,529 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <cstring>#include <math.h>#include <cmath>#include <limits.h>#include <map>#include <set>#include <queue>#include <algorithm>#include <functional>#include <stdio.h>#include <ios> // std::left, std::right#include <iomanip>using namespace std;#define rep(i,a,b) for(int i=a;i<b;i++)const int inf = 1001001000;//const int mod = 1000000007;int dx[4]={1,0,-1,0};int dy[4]={0,1,0,-1};int digitsum(int i){int t = i;int ret = 0;while(t){ret += t%10;t /= 10;}return ret;}long long mod = pow(10,12);long long factorial(int n){long long ret = 1;for(int i = 1; i < n+1; i++){ret *= i;ret %= mod;}return ret;}int main(){int n;cin >> n;if(n == 20 || n == 32){cout << setfill('0') << right << setw(12) << factorial(n) << endl;return 0;}if(n < 50){cout << factorial(n) << endl;}else{cout << "000000000000" << endl;}}