Codeforces 893E 数论
来源:互联网 发布:西安mac 编辑:程序博客网 时间:2024/05/21 20:22
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef vector<int> VI;const int N = 1000050;const ll mod = 1e9 + 7;template<class T>T read(){ T x = 0, f = 1; char ch = getchar(); while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar();} while(ch >= '0' && ch<= '9') { x = 10 * x + ch - '0'; ch = getchar();} return x * f;}ll fac[N], inv[N], q[N];VI vec[N];ll qpow(ll a, ll b, ll p){ ll res = 1 % p; while(b) { if(b & 1) res = res * a % p; a = a * a % p; b >>= 1; } return res;}void init(){ fac[1] = 1; for(int i = 2; i < N; ++i) fac[i] = fac[i - 1] * i % mod; q[0] = 1; for(int i = 1; i < N; ++i) q[i] = q[i - 1] * 2 % mod; inv[N - 1] = qpow(fac[N - 1], mod - 2, mod); for(int i = N - 2; i >= 0; --i) inv[i] = inv[i + 1] * (i + 1) % mod; for(int i = 2; i < N; ++i) { if(vec[i].empty()) for(int j = i; j < N; j += i) vec[j].push_back(i); }}ll C(int m, int n){ return fac[m] * inv[n] % mod * inv[m - n] % mod;}int main(){ init(); int T = read<int>(); while(T--) { int n = read<int>(), k = read<int>(); ll ans = 1; for(auto u : vec[n]) { int tmp = n, cnt = 0; while(tmp % u == 0) { ++cnt; tmp /= u; } ans = ans * C(cnt + k - 1, k - 1) % mod;; } ans = ans * q[k - 1] % mod; printf("%I64d\n", ans); } return 0;}
阅读全文
0 0
- Codeforces 893E 数论
- Codeforces 776E 数论
- Codeforces 711E 数论
- codeforces 837E 数论
- Codeforces 412E E-mail Addresses(数论)
- codeforces 446E E. Divisors(数论+暴力)
- codeforces 165E DP 数论 二进制
- codeforces #271E Three Horses 数论
- Codeforces Round #325 (Div. 2) E 数论
- Codeforces Round #395 (Div. 2) E(数论)
- CodeForces 448 E.Divisors(数论+递归)
- CodeForces 73 E.Morrowindows(数论)
- codeforces 337E E. Divisor Tree(数论+贪心)
- Codeforces Round #257 (Div. 2)E(数论+构造)
- Educational Codeforces Round 5 E. Sum of Remainders 数论
- Codeforces educational round 5. E Sum of Remainders 数论 分块
- 【数论】【分块】【乱搞】codeforces 616E Sum of Remainders
- CodeForces 616E Sum of Remainders(数论)
- Laravel之发送邮件到阿里云邮箱
- Linux下mongodb安装
- 笔记:shell脚本语法中比较运算符
- [牛客网]回文素数
- 求最小生成树的克鲁斯卡尔(Kruskal)算法
- Codeforces 893E 数论
- WIN10 VS2013 GTX960M NVIDIA显卡驱动和CUDA7.5安装 配置Caffe
- Sliding Window(单调队列讲解与例题)
- 纯CSS3动画之上下翻转
- Cantor表
- Retrofit各种姿势请求
- [牛客网]排序
- Hbase实战教程之happybase
- Raid5两块硬盘掉线怎么恢复数据_北亚案例