hdu 5525 Product 数论算贡献
Product
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
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.
0 1 1 0
5
1 2 3 4 5
473272463

#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 数论算贡献的更多相关文章
- HDU 5525 Product 数论
题意: 给出一个长度为\(n(1 \leq n \leq 10^5)\)的序列\(A_i\),\(N=\prod\limits_{i=1}^{n}i^{A_i}\).求\(N\)的所有约数的乘积. 分 ...
- 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 ...
- 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 ...
- HDU 5525:Product 欧拉定理
Product Accepts: 21 Submissions: 171 Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072 ...
- hdu GuGuFishtion 6390 数论 欧拉函数
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6390 直接开始证明: 我们设…………………………………….....…...............………… ...
- HDU 1299 基础数论 分解
给一个数n问有多少种x,y的组合使$\frac{1}{x}+\frac{1}{y}=\frac{1}{n},x<=y$满足,设y = k + n,代入得到$x = \frac{n^2}{k} + ...
- 2019ICPC西安邀请赛 - B. Product - 数论
打印的时候麻烦把:https://blog.csdn.net/skywalkert/article/details/50500009这个打印下来. 求\(\prod\limits_{i=1}^{n} ...
- 模拟+算贡献——cf1195D
比赛的时候没看到模数,用java大数在写,最后看到的时候已经慌了.. 把贡献算清楚就可以 下面是贡献的推导 有五位数 abcde * 10个 有两位数 fg * 3 个 那么这两种数组成的情况就是 a ...
- 2019牛客多校第七场 F Energy stones 树状数组+算贡献转化模拟
Energy stones 题意 有n块石头,每块有初始能量E[i],每秒石头会增长能量L[i],石头的能量上限是C[i],现有m次时刻,每次会把[s[i],t[i]]的石头的能量吸干,问最后得到了多 ...
随机推荐
- ubuntu,windows 卸载安装mysql
首先删除mysql: sudo apt-get remove mysql-* 1 然后清理残留的数据 dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dp ...
- u-boot SPL的理解
uboot分为uboot-spl和uboot两个组成部分.SPL是Secondary Program Loader的简称,第二阶段程序加载器,这里所谓的第二阶段是相对于SOC中的BROM来说的,之前的 ...
- DevExpress使用技巧总结
DevExpress是非常主流的.NET控件,目前全世界和中国都用很多用户使用,不过由于是英文版,初次接触的同学可能会觉得困难,这里就总结DevExpress常见的10个使用技巧. 1.TextEdi ...
- Lintcode: Insert Node in a Binary Search Tree
Given a binary search tree and a new tree node, insert the node into the tree. You should keep the t ...
- Summary: Java中函数参数的传递
函数调用参数传递类型(java)的用法介绍. java方法中传值和传引用的问题是个基本问题,但是也有很多人一时弄不清. (一)基本数据类型:传值,方法不会改变实参的值. public class Te ...
- sql server 视图的操作
-- 判断要创建的视图名是否存在if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[视图名]') and OBJ ...
- javascript 判断数据类型
Object.prototype.toString.call(asddfff) //报错asddfff没被定义Object.prototype.toString.call(undefined) //& ...
- hdu5195 二分+线段树+拓扑序
这题说的给了n个点m条边要求保证是一个有向无环图,可以删除至多k条边使得这个图的拓扑序的字典序最大,我们知道如果我们要排一个点的时候一定要考虑比他大的点是否可以.通过拆边马上拆出来,如果可以拆当然是拆 ...
- HIT 2051
这题说的是 一辆汽车 每走一单位的距离就消耗一单位的燃料,然后,他要回城里去,当然他与城镇之间有n个加油站 ,他的油箱可以为 无穷大 ,这样分析后发现进不进汽油站 与 汽油站在哪无关 ,只与加油站的 ...
- CAReplicatorLayer
CAReplicatorLayer CAReplicatorLayer的目的是为了高效生成许多相似的图层.它会绘制一个或多个图层的子图层,并在每个复制体上应用不同的变换.看上去演示能够更加解释这些,我 ...