Little Elephant and LCM

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long
using namespace std; const int N = 1e5 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-; int n, tot, tmp = , ans, a[N], b[N];
vector<int> fac[N]; int power(int a, int b) {
if(!a) return ;
int ans = ;
while(b) {
if(b & ) ans = 1ll * ans * a % mod;
a = 1ll * a * a % mod; b >>= ;
}
return ans;
} int main() {
for(int i = ; i < N; i++)
for(int j = i; j < N; j += i)
fac[j].push_back(i);
scanf("%d", &n);
for(int i = ; i <= n; i++) scanf("%d", &a[i]);
sort(a + , a + + n);
for(int i = ; i <= a[n]; i++, tot = , tmp = ) {
for(auto& t : fac[i]) b[++tot] = lower_bound(a + , a + + n, t) - a;
for(int i = ; i < tot; i++) tmp = 1ll * tmp * power(i, b[i + ] - b[i]) % mod;
ans = (ans + 1ll * tmp * power(tot, n + - b[tot]) % mod) % mod;
ans = (ans - 1ll * tmp * power(tot - , n + - b[tot]) % mod + mod) % mod;
}
printf("%d\n", ans);
return ;
} /*
*/

Codeforces 258C Little Elephant and LCM的更多相关文章

  1. codeforces 258C Little Elephant and LCM 组合数学 枚举

    题意: input : n a1,a2,...,an 1 <= n <= 10^5 1 <= ai <= 10^5 求b数组的方案数,b数组满足: 1. 1 <= bi ...

  2. CodeForces - 204C Little Elephant and Furik and Rubik

    CodeForces - 204C Little Elephant and Furik and Rubik 个人感觉是很好的一道题 这道题乍一看我们无从下手,那我们就先想想怎么打暴力 暴力还不简单?枚 ...

  3. Codeforces D. Little Elephant and Interval(思维找规律数位dp)

    题目描述: Little Elephant and Interval time limit per test 2 seconds memory limit per test 256 megabytes ...

  4. CodeForces 259A Little Elephant and Chess

     Little Elephant and Chess Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d &am ...

  5. CodeForces 221D Little Elephant and Array

    Little Elephant and Array Time Limit: 4000ms Memory Limit: 262144KB This problem will be judged on C ...

  6. Codeforces 204A Little Elephant and Interval

    http://codeforces.com/problemset/problem/204/A 题意:给定一个[L,R]区间,求这个区间里面首位和末尾相同的数字有多少个 思路:考虑这个问题满足区间加减, ...

  7. Codeforces 258D Little Elephant and Broken Sorting (看题解) 概率dp

    Little Elephant and Broken Sorting 怎么感觉这个状态好难想到啊.. dp[ i ][ j ]表示第 i 个数字比第 j 个数字大的概率.转移好像比较显然. #incl ...

  8. [Codeforces 204E] Little Elephant and Strings

    [题目链接] https://codeforces.com/contest/204/problem/E [算法] 首先构建广义后缀自动机 对于自动机上的每个节点 , 维护一棵平衡树存储所有它所匹配的字 ...

  9. CodeForces - 258D Little Elephant and Broken Sorting

    Discription The Little Elephant loves permutations of integers from 1 to n very much. But most of al ...

随机推荐

  1. 【刷题】BZOJ 4543 [POI2014]Hotel加强版

    Description 同OJ3522 数据范围:n<=100000 Solution dp的设计见[刷题]BZOJ 3522 [Poi2014]Hotel 然后发现dp的第二维与深度有关,于是 ...

  2. 【bzoj1044】木棍分割

    Description 有n根木棍, 第i根木棍的长度为Li,n根木棍依次连结了一起, 总共有n-1个连接处. 现在允许你最多砍断m个连接处, 砍完后n根木棍被分成了很多段,要求满足总长度最大的一段长 ...

  3. HGOI20180812 (NOIP2018 提高组 Day1 模拟试题)

    前缀数组其实就是有序的,那么答案显然是      我们尝试求出通项公式: 证明如下: 因为 所以: 解之得: 更加通俗的写法如下: 易知  令 那么, (错位相减) 由易知等式代入得, 所以, 所以程 ...

  4. java lock锁住特定对象

    由于lock没有锁住特定对象的概念,该如何做到像synchronized同步块一样的效果呢? 答案:为每一个需要加锁的对像分配一把锁. 示例: List<User> users = new ...

  5. C# 获取IIS站点及虚拟目录信息

    using System; using System.DirectoryServices; using System.Collections.Generic; using System.Text; n ...

  6. mongoDB的使用(NodeJs)

    MongoDB相信大家都不太陌生了,但是究竟它和我们熟悉的MySQL(MariaSQL).SQLServer有什么区别呢? 我们熟悉的MySQL是关系型数据,每个数据表都有严格的数据结构规定,因而我们 ...

  7. LSTM介绍

    转自:https://blog.csdn.net/gzj_1101/article/details/79376798 LSTM网络 long short term memory,即我们所称呼的LSTM ...

  8. python---django中url访问方法

    只是了解,不推荐使用,毕竟干扰太多,任意冲突,也没有解耦,应该使用路由分发 在url匹配中支持正则匹配,例如: from django.conf.urls import include, urlfro ...

  9. git clone错误 fatal: early EOF fatal: index-pack failed

    最后用ssh的方式解决了,不用http https://blog.csdn.net/fastjack/article/details/79757520 用了以下的方法还是不行 今天想 clone 一下 ...

  10. bzoj千题计划229:bzoj4424: Cf19E Fairy

    http://www.lydsy.com/JudgeOnline/problem.php?id=4424 图是二分图的条件:没有奇环 所以,如果图不存在奇环,删除任意一条边都可以 如果存在奇环, 对于 ...