結果

問題 No.502 階乗を計算するだけ
ユーザー xxxasdfghjk
提出日時 2018-10-28 17:44:47
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 863 bytes
コンパイル時間 1,294 ms
コンパイル使用メモリ 158,964 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-11-19 07:11:53
合計ジャッジ時間 19,898 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43 TLE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

int main()
{
  ll res=1,N,mod=10E8+7;
  cin >> N;
  if(N >= mod){
    res =0;
  }else if(N >= 250000000 && 499999999 <= N){
    res = 112390913;
    for(ll i=250000001;i<=N;i++){
      res = (res*i)%mod;
    }
  }else if(N >= 500000000 && 749999999 <= N){
    res = 733333339;
    for(ll i=500000001;i<=N;i++){
      res = (res*i)%mod;
    }
  }else if(N >= 750000000){
    res = 217598709;
    for(ll i=750000001;i<=N;i++){
      res = (res*i)%mod;
    }
  }else{
    for(ll i=1;i<=N;i++){
      res = (res*i)%mod;
    }
  }
  cout << res << endl;
  return 0;
}

0