結果

問題 No.645 Count Permutation
ユーザー 193s193s
提出日時 2018-02-03 12:24:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 1,212 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 92,620 KB
実行使用メモリ 27,020 KB
最終ジャッジ日時 2023-09-02 08:25:00
合計ジャッジ時間 3,047 ms
ジャッジサーバーID
(参考情報)
judge14 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 11 ms
7,712 KB
testcase_12 AC 7 ms
4,784 KB
testcase_13 AC 10 ms
7,752 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 43 ms
15,656 KB
testcase_16 AC 36 ms
13,744 KB
testcase_17 AC 86 ms
25,944 KB
testcase_18 AC 30 ms
11,568 KB
testcase_19 AC 93 ms
27,020 KB
testcase_20 AC 95 ms
26,876 KB
testcase_21 AC 70 ms
22,012 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 91 ms
26,852 KB
testcase_25 AC 50 ms
17,700 KB
testcase_26 AC 75 ms
23,920 KB
testcase_27 AC 42 ms
15,652 KB
testcase_28 AC 29 ms
11,580 KB
testcase_29 AC 69 ms
21,808 KB
testcase_30 AC 70 ms
21,796 KB
testcase_31 AC 76 ms
23,840 KB
testcase_32 AC 24 ms
9,556 KB
testcase_33 AC 23 ms
9,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }

int N;
long long L, R;
int dp[100001][60];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> L >> R;
  dp[N-1][0] = 1;
  for (int x=N-1; x>=1; x--) {
    rep(j, 60) {
      if (dp[x][j] == 0) continue;
      if (j+1<60) add(dp[x-1][j+1], dp[x][j]);
      add(dp[x-1][j], (1LL*(N-1-x)*dp[x][j])%MOD);
    }
  }
  int s = 0;
  rep(b, 60) {
    if (L <= (1LL<<b) && (1LL<<b) <= R) add(s, dp[0][b]);
  }
  if (L == 0) {
    int a = N-1;
    for (int i=1; i<=N-1; i++) a = (1LL*a*i) % MOD;
    add(s, a);
  }
  cout << s << "\n";
  return 0;
}
0