CodeForces
来源:互联网 发布:汝知其劳逸不 编辑:程序博客网 时间:2024/06/06 23:59
题意:
给你n个素数,有重复,把这n个数乘起来得到 N,然后找到他所有的因子,把这些因子再乘起来,对 1e9+7 取模
思路:
我们可以知道N的所有因子都是由给定的n个素数其中的一些相乘得到,所以我们又可以想到 答案就是n的所有子集相乘取模的结果,但是也难以实现
继续想,可以推出每个素数pi 给N的所有因子的贡献,也就是其中有多少个pi,根据排列组合可以推一下
#include<iostream>#include<algorithm>#include<cstdio>#include<cstdlib>#include<cstring>#include<string>#include<cmath>#include<set>#include<queue>#include<stack>#include<map>#define PI acos(-1.0)#define in freopen("in.txt", "r", stdin)#define out freopen("out.txt", "w", stdout)using namespace std;typedef long long ll;typedef unsigned long long ull;const int maxn = 5e5 + 7, maxd = 670000 + 7, mod = 1e9 + 7;const int INF = 0x7f7f7f7f;ll pow_(ll a, ll n) { a %= mod; ll res = 1; while(n) { if(n&1) res = (res*a) % mod; a = (a*a) % mod; n /= 2; } return res;}int main() { int n; scanf("%d", &n); map<int, int> cnt; for(int i = 0; i < n; ++i) { int x; scanf("%d", &x); cnt[x]++; } ll d = 1, ans = 1; for(auto x : cnt) { ll cnt = x.second; ll p = x.first; ll fp = pow_(p, (cnt+1)*cnt/2); ans = pow_(ans, (cnt+1)) * pow_(fp, d) % mod; d = d * (x.second+1)%(mod-1); } cout << ans << endl; return 0;}
阅读全文
1 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- spring基础
- HDU 4734 F[x] (数位dp)
- 【JavaScript学习】DOM操作技术
- 数据结构实验之图论三:判断可达性(DFS算法)
- 基于颜色分量HSV的图像分割:基于opencv的分割调试工具源码
- CodeForces
- java 线程的五种状态
- C++ bind
- C语言学习心得与体会1
- 阿里云 linux搭建git服务器
- bos项目day04快递员条件查询:ArrayList的toArray(T[] a)方法
- 用Java实现斐波拉契函数
- Mysql中转化固定日期类似Oracle中的to_char方法
- keras入门 利用卷积神经网络进行手写数字识别