Product

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)

Problem Description
Given a number sequence A1,A2....An,indicating N=∏ni=1iAi.What is the product of all the divisors of N?
 
Input
There are multiple test cases.
First line of each case contains a single integer n.(1≤n≤105)
Next line contains n integers A1,A2....An,it's guaranteed not all Ai=0.(0≤Ai≤105).
It's guaranteed that ∑n≤500000.
 
Output
For each test case, please print the answer module 109+7 in a line.
 
Sample Input
4
0 1 1 0
5
1 2 3 4 5
 
Sample Output
36
473272463
 
Source
 
题意:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pi (4*atan(1.0))
#define eps 1e-14
#define bug(x) cout<<"bug"<<x<<endl;
const int N=2e5+,M=4e6+,inf=;
const ll INF=1e18+,mod=1e9+; /// 数组大小
int prime(int n)
{
if(n<=)
return ;
if(n==)
return ;
if(n%==)
return ;
int k, upperBound=n/;
for(k=; k<=upperBound; k+=)
{
upperBound=n/k;
if(n%k==)
return ;
}
return ;
} vector<int>p;
int si[N];
void init()
{
for(int i=;i<=;i++)
if(prime(i))
p.push_back(i);
}
ll quick(ll a,ll b,ll c)
{
ll ans=;
while(b)
{
if(b&)ans=(ans*a)%c;
b>>=;
a=(a*a)%c;
}
return ans;
}
int main()
{
init();
int n;
while(~scanf("%d",&n))
{
memset(si,,sizeof(si));
for(int i=;i<=n;i++)
{
int z;
int x=i;
scanf("%d",&z);
for(int j=;j<p.size();j++)
{
if(1LL*p[j]*p[j]>x)break;
if(x==)break;
while(x%p[j]==)
{
si[j]+=z;
si[j]=(si[j])%(*(mod-));
x/=p[j];
}
}
if(x!=)
{
int pos=lower_bound(p.begin(),p.end(),x)-p.begin();
si[pos]+=z;
}
}
ll sum=;
for(int i=;i<p.size();i++)
{
sum*=(si[i]+);
sum%=(*(mod-));
}
//cout<<sum<<endl;
ll ans=;
for(int i=;i<p.size();i++)
{
ans=(ans*quick(p[i],((sum*si[i])%(*(mod-)))/,mod))%(mod);
}
printf("%lld\n",ans);
}
return ;
}

hdu 5525 Product 数论算贡献的更多相关文章

  1. HDU 5525 Product 数论

    题意: 给出一个长度为\(n(1 \leq n \leq 10^5)\)的序列\(A_i\),\(N=\prod\limits_{i=1}^{n}i^{A_i}\).求\(N\)的所有约数的乘积. 分 ...

  2. Codeforces Round #289 (Div. 2, ACM ICPC Rules) E. Pretty Song 算贡献+前缀和

    E. Pretty Song time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  3. hdu 5228 OO’s Sequence(单独取数算贡献)

    Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number o ...

  4. HDU 5525:Product 欧拉定理

    Product  Accepts: 21  Submissions: 171  Time Limit: 6000/3000 MS (Java/Others)  Memory Limit: 131072 ...

  5. hdu GuGuFishtion 6390 数论 欧拉函数

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=6390 直接开始证明: 我们设…………………………………….....…...............………… ...

  6. HDU 1299 基础数论 分解

    给一个数n问有多少种x,y的组合使$\frac{1}{x}+\frac{1}{y}=\frac{1}{n},x<=y$满足,设y = k + n,代入得到$x = \frac{n^2}{k} + ...

  7. 2019ICPC西安邀请赛 - B. Product - 数论

    打印的时候麻烦把:https://blog.csdn.net/skywalkert/article/details/50500009这个打印下来. 求\(\prod\limits_{i=1}^{n} ...

  8. 模拟+算贡献——cf1195D

    比赛的时候没看到模数,用java大数在写,最后看到的时候已经慌了.. 把贡献算清楚就可以 下面是贡献的推导 有五位数 abcde * 10个 有两位数 fg * 3 个 那么这两种数组成的情况就是 a ...

  9. 2019牛客多校第七场 F Energy stones 树状数组+算贡献转化模拟

    Energy stones 题意 有n块石头,每块有初始能量E[i],每秒石头会增长能量L[i],石头的能量上限是C[i],现有m次时刻,每次会把[s[i],t[i]]的石头的能量吸干,问最后得到了多 ...

随机推荐

  1. [py]你真的了解多核处理器吗? 了解多线程

    越来越多的人搞爬虫,设计到多线程爬取, 还有一些机器学习的一些模块也需要这玩意, 感觉自己不会逼格不高. 抽时间赶紧玩一玩这东西, 希望提高对软件的认知和归属感,不要太傻. cpu内部架构参考 你知道 ...

  2. jmeter 读取excel数据

    jmeter 读取excel数据使用的方法是使用Jmeter CSV Data Set Config参数化 但是将excel文件保存成csv格式后,jmeter读取后返回的数据总是出现乱码问题, 以下 ...

  3. C# 拓展方法实例

    namespace BenJi{ class Program { static void Main(string[] args) { Console.WriteLine("你要调试程序吗?y ...

  4. Integer类之equals与hashCode

    一.源码. 1.equals源码.可以看出,比较的是两者的类型相同且内容相同.即是否有相等的int类型的value值. ######################################## ...

  5. hexo修改Next主题的样式

    Next主题默认对超链接只有下划线样式,很容易被忽略,就想着怎么修改下 主题样式是在\hexoBlog\themes\next\source\css,这里面保存了Muse,Mist和Pisces三个主 ...

  6. SVA描述(一)

    SystemVerilog Assertion(SVA):是一种描述性的语言,可以很容易的描述时序相关的情况,所以主要用在协议检查和协议覆盖.SVA在systemverilog仿真器中的 调度区间在R ...

  7. Asp.net MVC 通过自定义ControllerFactory实现构造器注入

    一.重写ControllerFactory的GetControllerInstance ControllerFactory是asp.net中用于在运行时构造Controller的工厂 ,默认使用的工厂 ...

  8. linux常用命令:diff 命令

    diff 命令是 linux上非常重要的工具,用于比较文件的内容,特别是比较两个版本不同的文件以找到改动的地方.diff在命令行中打印每一个行的改动.最新版本的diff还支持二进制文件.diff程序的 ...

  9. TED #10# A rite of passage for late life

    Bob Stein: A rite of passage for late life Collection I grew up white, secular and middle class in 1 ...

  10. P3627 [APIO2009]抢掠计划

    P3627 [APIO2009]抢掠计划 Tarjan缩点+最短(最长)路 显然的缩点...... 在缩点时,顺便维护每个强连通分量的总权值 缩完点按照惯例建个新图 然后跑一遍spfa最长路,枚举每个 ...