不难想到对
x
x
x分解后,得到
x
=
p
1
c
1
∗
.
.
p
i
c
i
x=p_1^{c1}*..p_i^{c_i}
x=p1c1∗..pici 每一项
c
i
c_i
ci的分配都是独立的,问题转化为对每一项
c
i
c_i
ci分配位置,类似多重集的组合数。 那么负数怎么理解呢,因为最后得到的数字是正数,就是挑0,2,4,6,8…个位置取符号,该系数是二项式系数的偶数项之和
2
n
−
1
2^{n-1}
2n−1
/*
Stairs upon the temple
I climb and I crawl in
People travel millions of miles just to see it
But they never conquer this way
*/
#include
using namespace std;
const int maxn = 1e6+5;
const int INF = 1e9+7;
typedef long long ll;
typedef pair pii;
#define all(a) (a).begin(), (a).end()
#define pb(a) push_back(a)
vector G[maxn];
const int mod = INF;
int vis[maxn];ll inv[2*maxn];
ll pw(ll a,ll b){
ll ans = 1;a%=mod;
while(b){
if(b&1) ans = ans*a%mod;
a =a*a%mod;b>>=1;
}
return ans%mod;
}
ll fac[maxn*2];
void init(int n){
vis[1] = 1;
for(int i=2;iT;
while(T--){
int x,n;cin>>x>>n;
ll ans = 1;
while(x!=0&&x!=1){
ll cnt = get(x);
if(cnt==0) break;
ans = ans * C(n+cnt-1,n-1) %mod;
}
ans = ans * pw(2,n-1)%mod;
cout
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?