結果
| 問題 | No.500 階乗電卓 |
| コンテスト | |
| ユーザー |
btk
|
| 提出日時 | 2017-04-08 00:06:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,037 bytes |
| コンパイル時間 | 1,564 ms |
| コンパイル使用メモリ | 168,396 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 02:53:58 |
| 合計ジャッジ時間 | 2,377 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define CIN_ONLY if(1)
struct cww{cww(){
CIN_ONLY{
ios::sync_with_stdio(false);cin.tie(0);
}
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
for(auto &it:v)is>>it;
return is;
}
typedef __int128 INT;
int main(){
LL N;
cin>>N;
INT ret=1;
int dig=0;
const LL mod=1e12;
FOR(i,1,min(1000ll,N+1)) {
ret=ret*i;
if(ret>=mod)dig=1;
ret%=mod;
}
string s=to_string((LL)ret);
if(dig)while(s.size()<12)s="0"+s;
cout<<s<<endl;
return 0;
}
btk