結果

問題 No.645 Count Permutation
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2018-06-03 12:56:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 75,772 KB
実行使用メモリ 58,108 KB
最終ジャッジ日時 2023-09-12 21:48:47
合計ジャッジ時間 3,664 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 15 ms
12,232 KB
testcase_12 AC 10 ms
8,592 KB
testcase_13 AC 14 ms
11,884 KB
testcase_14 AC 4 ms
4,448 KB
testcase_15 AC 53 ms
38,424 KB
testcase_16 AC 46 ms
33,376 KB
testcase_17 AC 90 ms
57,488 KB
testcase_18 AC 39 ms
29,544 KB
testcase_19 AC 89 ms
58,108 KB
testcase_20 AC 89 ms
54,684 KB
testcase_21 AC 78 ms
53,584 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 89 ms
57,912 KB
testcase_25 AC 60 ms
30,692 KB
testcase_26 AC 81 ms
55,528 KB
testcase_27 AC 53 ms
26,508 KB
testcase_28 AC 39 ms
29,260 KB
testcase_29 AC 76 ms
53,292 KB
testcase_30 AC 77 ms
53,408 KB
testcase_31 AC 81 ms
55,672 KB
testcase_32 AC 31 ms
16,512 KB
testcase_33 AC 32 ms
16,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const lint mod=1e9+7;
lint dp[65][110000];

int main(){
  int n;lint l,r;cin>>n>>l>>r;
  dp[0][0]=1;
  for(int k=0;k<=64;++k){
    for(int i=1;i<=n;++i){
      dp[k][i]=(i-1)*dp[k][i-1]%mod;
      if(k>=1)
        dp[k][i]=(dp[k][i]+dp[k-1][i-1])%mod;
    }
  }
  lint taplis=1;
  rep(i,n-1)taplis=taplis*(i+1)%mod;
  taplis=taplis*(n-1)%mod;
  lint ans=l==0?taplis:0;
  rep(i,64)
    if(l<=1LL<<i&&1LL<<i<=r)ans=(ans+dp[i][n-1])%mod;
  cout<<ans<<endl;
}
0