根据f求出概率再*(n-k)*num就行,但求出的数可能是个小数,所以求概率时要用到逆元。
#include
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
map mp;
map mp2;
ll num[100];
ll sum=0;
long long x,y;
ll power(ll a,ll b)
{
ll c=1;
for(;b;b>>=1)
{
if(b&1) c=(long long)c*a%mod;
a=(long long)a*a%mod;
}
return c;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
sum=0;
mp.clear();
mp2.clear();
ll n,k;
scanf("%lld%lld",&k,&n);
for(int i=0;i>t;
sum=(sum+t)%mod;
}
for(int i=0;i>t;
num[i]=t;
mp[t]++;
}
ll ni=power(k,mod-2);
for(int i=0;i