Codeforces 258C 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的更多相关文章
- codeforces 258C Little Elephant and LCM 组合数学 枚举
题意: input : n a1,a2,...,an 1 <= n <= 10^5 1 <= ai <= 10^5 求b数组的方案数,b数组满足: 1. 1 <= bi ...
- CodeForces - 204C Little Elephant and Furik and Rubik
CodeForces - 204C Little Elephant and Furik and Rubik 个人感觉是很好的一道题 这道题乍一看我们无从下手,那我们就先想想怎么打暴力 暴力还不简单?枚 ...
- Codeforces D. Little Elephant and Interval(思维找规律数位dp)
题目描述: Little Elephant and Interval time limit per test 2 seconds memory limit per test 256 megabytes ...
- CodeForces 259A Little Elephant and Chess
Little Elephant and Chess Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d &am ...
- CodeForces 221D Little Elephant and Array
Little Elephant and Array Time Limit: 4000ms Memory Limit: 262144KB This problem will be judged on C ...
- Codeforces 204A Little Elephant and Interval
http://codeforces.com/problemset/problem/204/A 题意:给定一个[L,R]区间,求这个区间里面首位和末尾相同的数字有多少个 思路:考虑这个问题满足区间加减, ...
- Codeforces 258D Little Elephant and Broken Sorting (看题解) 概率dp
Little Elephant and Broken Sorting 怎么感觉这个状态好难想到啊.. dp[ i ][ j ]表示第 i 个数字比第 j 个数字大的概率.转移好像比较显然. #incl ...
- [Codeforces 204E] Little Elephant and Strings
[题目链接] https://codeforces.com/contest/204/problem/E [算法] 首先构建广义后缀自动机 对于自动机上的每个节点 , 维护一棵平衡树存储所有它所匹配的字 ...
- 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 ...
随机推荐
- hdwiki5.1 词条参考资料都是相同的问题解决
HDWiki 5.1版本存在的BUG,当一个词条添加参考资料后,所有词条均显示以此相同的参考资料:而且参考资料不能修改和删除! 解决方法如下: 找到后台文件:\model\reference.clas ...
- MT【170】裂项相消
已知$a,b>0$证明:$\dfrac{1}{a+2b}+\dfrac{1}{a+4b}+\dfrac{1}{a+6b}<\dfrac{3}{\sqrt{(a+b)(a+7b)}}$ 证明 ...
- NOIP 2018 记
“这个时刻总是会来临的,日夜磨砺的剑锋,能否在今天展现出你的利刃呢?” 十一月十一日的紫荆港,早上的空气有些冷瑟.面对未知的$Day1$,我的心里尚且没有多少底数. $T1$是一道原题,也不难,并没有 ...
- solr与mysql数据同步的方案
1.使用activeMQ http://blog.csdn.net/zhou2s_101216/article/details/77855413 2.通过配置实现定时同步 http://blog.cs ...
- k8s pod的4种网络模式最佳实战(externalIPs )
[k8s]k8s pod的4种网络模式最佳实战(externalIPs ) hostPort相当于docker run -p 8081:8080,不用创建svc,因此端口只在容器运行的vm ...
- ngx_lua_API 指令详解(三)怎样理解 cosocket指令
参考:https://moonbingbing.gitbooks.io/openresty-best-practices/content/ngx_lua/whats_cosocket.html 春哥演 ...
- Mybatis 使用 mapper 接口规范的 一对一, 一对多,多对多映射
首先的 是 最原始的 pojo 类来 做简单映射 简单 pojo 映射: <mapper namespace="com.ghc.dao.UserDao"> <se ...
- js异步处理工作机制
js异步处理工作机制 从基础的层面来讲,理解JavaScript的定时器是如何工作的是非常重要的.计时器的执行常常和我们的直观想象不同,那是因为JavaScript引擎是单线程的.我们先来认识一下 ...
- [转载]JavaScript 的轻框架开发
http://www.open-open.com/news/view/1d64fed 为什么我们不用 Angular, Ember 或者 Backbone! Muut 是一个特殊的论坛平台,它也有着巨 ...
- 五行代码终极完美解决从IE6到Chrome所有浏览器的position:fixed;以及闪动问题
这个方法其实已经使用很久了,之前主要在嵌入式WebQQ等产品中用过,现在拿出来分享一下吧,是目前最简洁的方式来实现ie6的position:fixed; 失效bug,以及的其他方法的闪动问题,CSS代 ...