結果

問題 No.502 階乗を計算するだけ
ユーザー sugarrrsugarrr
提出日時 2018-08-29 20:49:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,854 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 81,544 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-11 20:39:28
合計ジャッジ時間 5,603 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 1 ms
4,368 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 1 ms
4,368 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 1 ms
4,368 KB
testcase_10 AC 2 ms
4,368 KB
testcase_11 AC 2 ms
4,372 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,368 KB
testcase_14 AC 1 ms
4,372 KB
testcase_15 AC 2 ms
4,372 KB
testcase_16 AC 2 ms
4,372 KB
testcase_17 AC 2 ms
4,372 KB
testcase_18 AC 1 ms
4,372 KB
testcase_19 AC 1 ms
4,372 KB
testcase_20 AC 2 ms
4,372 KB
testcase_21 AC 2 ms
4,368 KB
testcase_22 AC 7 ms
4,372 KB
testcase_23 AC 3 ms
4,368 KB
testcase_24 AC 6 ms
4,372 KB
testcase_25 AC 2 ms
4,372 KB
testcase_26 AC 4 ms
4,372 KB
testcase_27 AC 3 ms
4,368 KB
testcase_28 AC 3 ms
4,372 KB
testcase_29 AC 3 ms
4,372 KB
testcase_30 AC 7 ms
4,372 KB
testcase_31 AC 5 ms
4,368 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

////////////////////////////////////////

ll data[101]={1,250015370,777847830,64381203,129227219,664720426,220551652,805011386,71626953,368173468,388742192,633943807,546160751,248863345,642800490,227253170,217956259,448399780,343122361,203128902,904824556,976400196,409788350,969665321,942841378,78633765,46429647,419288563,622773713,43950471,158036420,539867530,629028067,98679775,181067811,577131628,448714637,274699378,172718980,524877565,132400827,283566441,299777072,688241748,422054382,789638131,386613162,219084929,375238282,270146387,647619052,871756271,645927523,483519685,459833872,273602905,929096963,250231633,278589981,849449796,541794170,601214344,860331963,898831734,959047580,990713044,218658983,293444525,385243308,352821537,722869575,381109223,378511108,85458370,915965688,815695490,160874373,185206871,724450461,862837188,463715736,360855087,398991956,806738292,541775025,609437737,40420676,773978131,742263715,320097016,446595916,239856470,851897254,213673769,51083743,328555850,784853394,300038049,426045335,808434455,900198419};

int main(){
    ll n;cin>>n;
    ll m=n/(ll)(1E7);
    ll ans=data[m];
    rep(i,m*(ll)(1E7)+1,n){
        ans=mod(ans*i);
    }
    cout<<ans<<endl;
    
    return 0;
}
0