結果

問題 No.502 階乗を計算するだけ
ユーザー face4
提出日時 2018-11-03 11:49:41
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 547 ms / 1,000 ms
コード長 526 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 65,100 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-20 18:34:27
合計ジャッジ時間 5,223 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;

    const ll mod = 1000000007;

    if(n >= mod){
        cout << 0 << endl;
        return 0;
    }

    ll ume[11] = {1, 927880474, 933245637, 668123525, 429277690, 733333339, 
                    724464507, 957939114, 203191898, 586445753, 698611116};

    ll x = 100000000;
    ll ans = ume[n/x];

    for(ll i = n/x*x+1; i <= n; i++){
        ans *= i;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}
0