結果
| 問題 |
No.645 Count Permutation
|
| コンテスト | |
| ユーザー |
夕叢霧香(ゆうむらきりか)
|
| 提出日時 | 2018-06-03 12:56:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 98 ms / 2,000 ms |
| コード長 | 651 bytes |
| コンパイル時間 | 1,026 ms |
| コンパイル使用メモリ | 73,580 KB |
| 最終ジャッジ日時 | 2025-01-05 10:48:34 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#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;
}
夕叢霧香(ゆうむらきりか)