2015-05-27
The Little Elephant loves the LCM (least common multiple) operation of a non-empty set of positive integers. The result of the LCM operation of k positive integers x1,?x2,?...,?xk is the minimum positive integer that is divisible by each of numbers xi.
Let's assume that there is a sequence of integers b1,?b2,?...,?bn. Let's denote their LCMs as lcm(b1,?b2,?...,?bn) and the maximum of them as max(b1,?b2,?...,?bn). The Little Elephant considers a sequence b good, if lcm(b1,?b2,?...,?bn)?=?max(b1,?b2,?...,?bn).
The Little Elephant has a sequence of integers a1,?a2,?...,?an. Help him find the number of good sequences of integers b1,?b2,?...,?bn, such that for all i (1?≤?i?≤?n) the following condition fulfills: 1?≤?bi?≤?ai. As the answer can be rather large, print the remainder from dividing it by 1000000007 (109?+?7).
InputThe first line contains a single positive integer n (1?≤?n?≤?105) ― the number of integers in the sequence a. The second line contains nspace-separated integers a1,?a2,?...,?an (1?≤?ai?≤?105) ― sequence a.
OutputIn the single line print a single integer ― the answer to the problem modulo 1000000007 (109?+?7).
Sample test(s)41 4 3 2output
15input
26 3output
13
题意:
给你一个a序列,找出一个b序列,1?≤?bi?≤?ai,使得max(bi)=lcm(bi),问这样的bi序列有多少个。
思路:
先对a排序,枚举i=max(bi),对i因式分解,那么大于等于i的部分很好处理,直接pow_mod()相减,小于i的部分就任意取一个约束就够了。
代码:
#include#include #include #include #include #include#define INF 0x3f3f3f3f#define maxn 100005#define mod 1000000007typedef long long ll;using namespace std;int n;int a[maxn];ll pow_mod(ll x,ll n){ ll res = 1; while(n) { if(n&1) res = res * x %mod; x = x * x %mod; n >>= 1; } return res;}void solve(){ int i,j; ll ans=0,res; sort(a+1,a+n+1); for(i=1;ifac; for(j=1;j*j
1
CI框架连接数据库配置操作以及多数据库操作
09-05
2
asp 简单读取数据表并列出来 ASP如何快速从数据库读取大量数据
05-17
3
C语言关键字及其解释介绍 C语言32个关键字详解
04-05
4
C语言中sizeof是什么意思 c语言里sizeof怎样用法详解
04-26
5
最简单的asp登陆界面代码 asp登陆界面源代码详细介绍
04-12
6
PHP中的魔术方法 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep,
09-05
7
PHP中的(++i)前缀自增 和 (i++)后缀自增
09-05
8
PHP中include和require区别之我见
09-05
常用dos命令及语法
2014-09-27
将视频设置为Android手机开机动画的教程
2014-12-11
php递归返回值的问题
2014-09-05
如何安装PHPstorm并配置方法教程 phpstorm安装后要进行哪些配置
2017-05-03
java中的info是什么意思
2022-03-24
PHP 教程之如何使用BLOB存取图片信息实例
2014-09-05
IcePHP框架中的快速后台中的通用CRUD功能框架
2014-09-05
单片机编程好学吗?单片机初学者怎样看懂代码
2022-03-21
PHP数组函数array
2014-09-05
学ug编程如何快速入门?
2022-03-17
神灵部落官方下载v2.0 安卓版
卡牌对战 11.3M
下载权利之王手游官方版(SOT)下载v1.1.0 安卓版
策略塔防 124.5M
下载无限命运之弦游戏下载v1.11.27 安卓版
策略塔防 300.5M
下载我的咸鱼卡组游戏下载v0.2 安卓版
卡牌对战 229M
下载儿童宝宝认蔬菜游戏下载v35.10 安卓版
其它手游 127.8M
下载式公主手游(ひねもす式姫)下载v2.0.2 安卓版
经营养成 65.8M
下载境界死神激斗苹果版下载v1.37.12 官方iPhone版
其它手游 3G
下载聊斋搜灵录九游版下载v6.1.5 安卓版
其它手游 1.13G
下载埃克斯幻想超v版下载v3.0.1.3 安卓变态版
下载
flight color手游(飞行色彩)下载v1.0.4 安卓版
下载
快点三国bt版下载v200031 安卓变态版
下载
仙境传说起始国际服手游(ragnarok begins)下载v1.17.2 安卓版
下载
我的安妮国际服游戏下载v3.0.0 安卓版
下载
红色警戒4游戏(红警4
下载
彩色点点战争手游下载v1.0.4 安卓版
下载
最后的原始人手游九游客户端下载v1.1.66 安卓版
下载