1 solutions
-
0
#include #include #include<math.h> #include #include #include #include #include #include #define ll long long
typedef std::pair<ll,ll> pr; typedef std::pair<double,pr> zhs; const ll mod=1e9+7; const ll maxn=1e6+10; ll n,k,ans; ll c[maxn],inv[maxn]; double lg[maxn]; std::priority_queue q;
inline ll ksm(ll a,ll b,ll p) { ll ret=1; while(b) { if(b&1) ret=reta%p; a=aa%p; b>>=1; } return ret; }
inline void ny(ll m) { c[1]=1; for(int i=2;i<=m;i++) { c[i]=c[i-1]%mod*i%mod; } inv[m]=ksm(c[m],mod-2,mod); inv[m]=(inv[m]+mod)%mod; for(int i=m-1;i>=0;i--) { inv[i]=(i+1)*inv[i+1]%mod; inv[i]=(inv[i]+mod)%mod; } for(int i=1;i<=m;i++) {
} }
int main(void) { scanf("%lld %lld",&n,&k);
ny(n+2);
// for(int i=1;i<=n;i++) // { // printf("%lld %lld %.3lf\n",c[i],inv[i],lg[i]); // } // for(int i=0;i<=n;i++) { q.push(zhs(lg[n]-lg[i]-lg[n-i],pr(n,i))); }
for(int i=1;i<=k;i++) { ll d=q.top().second.first; ll m=q.top().second.second; q.pop(); (ans+=(c[d]*inv[m]%mod*inv[d-m]%mod))%=mod; d-=1; q.push(zhs(lg[d]-lg[m]-lg[d-m],pr(d,m))); } printf("%lld\n",ans); return 0;
}
- 1
Information
- ID
- 3319
- Time
- 1000ms
- Memory
- 250MiB
- Difficulty
- 6
- Tags
- # Submissions
- 2
- Accepted
- 1
- Uploaded By