题目链接

题意:给你两个数x,yx,yx,y,让你构造一些长为yyy的数列,让这个数列的累乘为xxx,输出方案数。

思路:考虑对xxx进行质因数分解,设某个质因子PiP_iPi​的的幂为kkk,则这个质因子的贡献就相当于把kkk个PiP_iPi​放到yyy个盒子中,且盒子可能为空,方案为C(k+y−1,y)C(k+y-1,y)C(k+y−1,y),然后每个质因子的方案乘在一起即可。最后,因为负号也会出现,但xxx为正,所以就是在yyy个位置上选偶数个位置放负号,方案为2y−12^{y-1}2y−1再乘起来即可。

#include<bits/stdc++.h>

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back using namespace std; LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e6 +11;
const LL mod=1e9+7;
LL Fac[N+33],Inv[N+33];
int p[N+33],a[N+33],cnt;
void init(){
Fac[0]=1;
for(int i=1;i<=N;i++)Fac[i]=(Fac[i-1]*i)%mod;
Inv[N]=powmod(Fac[N],mod-2,mod);
for(int i=N-1;i>=1;i--)Inv[i]=(Inv[i+1]*(i+1))%mod;
Inv[0]=1;
}
void P(){
for(int i=2;i<N;i++){
if(!p[i])a[++cnt]=i;
for(int j=1;j<=cnt&&1ll*a[j]*i<N;j++){
p[a[j]*i]=1;
if(i%a[j]==0)break;
}
}
}
LL C(int x,int y){
return 1ll*Fac[x]*Inv[y]%mod*Inv[x-y]%mod;
}
int main(){
ios::sync_with_stdio(false);
init();
int t;
P();
for(cin>>t;t;t--){
int x,y;
cin>>x>>y;
LL ans=1;
for(int i=1;i<=cnt&&1ll*a[i]*a[i]<=x;i++){
if(x%a[i]==0){
int res=0;
while(x%a[i]==0)res++,x/=a[i];
ans=ans*C(res+y-1,y-1);
ans%=mod;
}
}
if(x>1)ans=ans*C(y,y-1)%mod;
cout<<ans*powmod(2,y-1,mod)%mod<<endl;
}
return 0;
}

Educational Codeforces Round 33 (Rated for Div. 2) E. Counting Arrays的更多相关文章

  1. Educational Codeforces Round 33 (Rated for Div. 2) F. Subtree Minimum Query(主席树合并)

    题意 给定一棵 \(n\) 个点的带点权树,以 \(1\) 为根, \(m\) 次询问,每次询问给出两个值 \(p, k\) ,求以下值: \(p\) 的子树中距离 \(p \le k\) 的所有点权 ...

  2. Educational Codeforces Round 33 (Rated for Div. 2) 题解

    A.每个状态只有一种后续转移,判断每次转移是否都合法即可. #include <iostream> #include <cstdio> using namespace std; ...

  3. Educational Codeforces Round 33 (Rated for Div. 2)A-F

    总的来说这套题还是很不错的,让我对主席树有了更深的了解 A:水题,模拟即可 #include<bits/stdc++.h> #define fi first #define se seco ...

  4. Educational Codeforces Round 33 (Rated for Div. 2) D. Credit Card

    D. Credit Card time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  5. Educational Codeforces Round 33 (Rated for Div. 2) C. Rumor【并查集+贪心/维护集合最小值】

    C. Rumor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...

  6. Educational Codeforces Round 33 (Rated for Div. 2) B. Beautiful Divisors【进制思维/打表】

    B. Beautiful Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  7. Educational Codeforces Round 33 (Rated for Div. 2) A. Chess For Three【模拟/逻辑推理】

    A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  8. Educational Codeforces Round 33 (Rated for Div. 2)

    A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. Educational Codeforces Round 33 (Rated for Div. 2) D题 【贪心:前缀和+后缀最值好题】

    D. Credit Card Recenlty Luba got a credit card and started to use it. Let's consider n consecutive d ...

随机推荐

  1. elementUI el-table渲染的时候出现bug

    如下: 问题: value的值一直渲染不出来,因为是boolean类型,出现了bug,把true变成一个字符串就能显示了,太不好用了 为了能渲染出来,不得不写成下列形式:

  2. linux用户身份和文件权限

    1.用户身份与能力 root管理员是linux 的超级用户,他拥有系统的所有权,能够管理系统的各项功能,如添加/删除用户,启动/关闭服务进程,开启/禁用硬件设备…… "Linux系统中的管理 ...

  3. TNS-12535/12606 and ORA-3136 on Connection to Database (Doc ID 2313573.1)

    今天遇到一问题 telnet 都是通的,但是两台数据库服务器还是无法 sqlplus 连接 ,最后发现 两台服务器的 mtu 值不同,其中一台为 1500 一台为9000, 以前只是认为 telnet ...

  4. redhat 6.5 安装和配置zabbix客户端

    一.安装zabbix-agent端 rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6. ...

  5. 想了解SAW,BAW,FBAR滤波器的原理?看这篇就够了!

    想了解SAW,BAW,FBAR滤波器的原理?看这篇就够了!   很多通信系统发展到某种程度都会有小型化的趋势.一方面小型化可以让系统更加轻便和有效,另一方面,日益发展的IC**技术可以用更低的成本生产 ...

  6. BZOJ3709 Bohater 贪心

    传送门 思路很妙-- 有个前提条件:血量无限,这样话肯定先打会回血的怪,再打会掉血的怪 对于会回血的怪,按照受到伤害的顺序从小往大打 对于会掉血的怪似乎并不是很好搞,考虑:将每一时刻的血量函数画出来, ...

  7. 为什么Fourier分析?

    本文旨在给出Fourier分析的几个动机. 目录 波动方程 热导方程 Lapalce变换 求和公式 表示论 特征理论 参考资料 波动方程 考虑一维的波动方程最简单的边值问题$$u(x,t), x\in ...

  8. BugPhobia开发篇章:Beta阶段第X次Scrum Meeting

    0x01 :Scrum Meeting基本摘要 Beta阶段第十次Scrum Meeting 敏捷开发起始时间 2015/12/29 00:00 A.M. 敏捷开发终止时间 2016/01/01 23 ...

  9. idea注册码到期,破解idea

    http://idea.lanyus.com/    

  10. Kubernetes一键部署利器:kubeadm

    要真正发挥容器技术的实力,你就不能仅仅局限于对 Linux 容器本身的钻研和使用. 这些知识更适合作为你的技术储备,以便在需要的时候可以帮你更快的定位问题,并解决问题. 而更深入的学习容器技术的关键在 ...