結果
| 問題 |
No.645 Count Permutation
|
| コンテスト | |
| ユーザー |
Pulmn
|
| 提出日時 | 2017-08-23 21:07:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 2,000 ms |
| コード長 | 418 bytes |
| コンパイル時間 | 606 ms |
| コンパイル使用メモリ | 62,544 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-31 06:47:20 |
| 合計ジャッジ時間 | 2,321 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
const ll mod=1e9+7;
ll n,l,r;
int main(){
cin>>n>>l>>r;
vl dp(n);
dp[0]=1;
ll x=2,res=0;
if(!l){
res=n-1;
for(int i=1;i<n;i++) (res*=i)%=mod;
}
while(x<=r){
vl DP(n+1);
for(int i=1;i<n;i++) DP[i]=((n-i)*DP[i-1]+dp[i-1])%mod;
dp=DP;
if(l<=x) (res+=dp[n-1])%=mod;
x*=2;
}
cout<<res<<endl;
}
Pulmn