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]]的石头的能量吸干,问最后得到了多 ...
 
随机推荐
- poj2524(简单并查集)
			
#include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>u ...
 - POJ1789:Truck History(Prim算法)
			
http://poj.org/problem?id=1789 Description Advanced Cargo Movement, Ltd. uses trucks of different ty ...
 - selenium python 启动Chrome
			
启动Chrom浏览器 下载chromedriver: http://chromedriver.storage.googleapis.com/index.html 当时找chromedriver与chr ...
 - HDU 1392 Surround the Trees(几何 凸包模板)
			
http://acm.hdu.edu.cn/showproblem.php?pid=1392 题目大意: 二维平面给定n个点,用一条最短的绳子将所有的点都围在里面,求绳子的长度. 解题思路: 凸包的模 ...
 - 人生苦短之我用Python篇(socket编程)
			
socket模块 实现简单的远程连接: 客户端: import socket client = socket.socket()#声明socket类型,同时生成socke连接t对象 client.con ...
 - 在notepad++里面使用正则表达式替换掉所有行逗号前面内容
			
需求:在notepad++里面使用正则表达式替换掉所有行逗号前面内容,一文本内容如下(只贴一小部分,实际上N多): 级别,層級程序,程式插件,外掛程式鼠标,滑鼠打印,列印打开,開啟博客,部落格联系,聯 ...
 - jQuery 对象
			
jQuery 对象 版权声明:未经博主授权,严禁转载分享 什么是 jQuery 对象 jQuery 对象是通过 jQuery 包装 DOM 对象后产生的对象. jQuery 对象是一个类数组对象. j ...
 - zabbix zabbix_agentd.conf详解
			
# This is a config file for the Zabbix agent daemon (Unix) # To get more information about Zabbix, v ...
 - 利用脚本kill掉进程, 语法:运行脚本+进程名
			
下面附上脚本, 权限需要附X执行 #!/bin/sh #pid kill thread for chenglee #if fileformat=dos, update fileformat=unix ...
 - 20145104张家明 《Java程序设计》第四次实验设计
			
20145104张家明 <Java程序设计>第四次实验设计 这第四次实验报告 我们开始着手安卓了 在电脑上安装了安卓虚拟机