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. logstash采集tomcat日志、mysql错误日志

    input{ file { path => "/opt/Tomcat7.0.28/logs/*.txt" start_position => "beginni ...

  2. #C++初学记录(ACM试题2)

    Max Sum Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-seq ...

  3. 强大的chrome(1)以acfun为例抓取视频

    chrome很强大,很强大,很强大. 想要了解他的强大呢,就先要掌握一些基本的chrome命令. 1. chrome://flags   可用来启用或者关闭某些chrome的体验特性   2. chr ...

  4. lnmp1.4 安装php fileinfo扩展 方法

    第一步:在lnmp1.4找到php安装的版本 使用命令 tar   -jxvf   php-7.1.7.tar.bz2 解压 第二步: 在解压的php-7.1.7文件夹里找到fileinfo文件夹,然 ...

  5. 统计方法运行时间【Java实现】

    接口Command:定义命令的执行操作 package common; public interface Command { // 运行方法 void run(); } CommandRuntime ...

  6. 功能测试三剑客:测试框架、bug预防、探索性测试

    功能测试有一套框架来实现完整的覆盖测试的各个维度 测试框架: 参加本人之前的博客测试框架(包括总体的框架.web测试框架.PC客户端.手机客户端.服务器端.接口测试)六部分,罗列了各个领域的测试覆盖考 ...

  7. MATERIALIZED VIEW-物化视图

     Oracle的实体化视图提供了强大的功能,可以用在不同的环境中,实体化视图和表一样可以直接进行查询.实体化视图可以基于分区表,实体化视图本身也可以分区. 主要用于预先计算并保存表连接或聚集等耗时较多 ...

  8. sql server deadlock跟踪的四种方法

    最近写程序常会遇到deadlock victim,每次一脸懵逼.研究了下怎么跟踪,写下来记录下. 建测试数据 CREATE DATABASE testdb; GO USE testdb; CREATE ...

  9. 又一国产855旗舰突然现身:支持5G

    12月28日消息,中国联通官方微博放出了vivo NEX 5G版样机.如图所示,该机搭载骁龙855移动平台及X50 5G调制解调器. 早在8月30日,vivo就宣布完成了面向商用5G智能手机的软硬件开 ...

  10. MySQL数据库----存储过程

    存储过程 存储过程包含了一系列可执行的sql语句,存储过程存放于MySQL中,通过调用它的名字可以执行其内部的一堆sql -- 存储过程的优点: -- 1.程序与数据实现解耦 -- 2.减少网络传输的 ...