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 ...
随机推荐
- 洛谷P4172 [WC2006]水管局长 (LCT,最小生成树)
洛谷题目传送门 思路分析 在一个图中,要求路径上最大边边权最小,就不难想到最小生成树.而题目中有删边的操作,那肯定是要动态维护啦.直接上LCT维护边权最小值(可以参考一下蒟蒻的Blog) 这时候令人头 ...
- 手动生成moc文件
在VS中写Qt项目时,手动添加了一个类,由于要用到信号槽,所以需要生成相应的moc文件.写好信号槽以后,在类里面第一行应该写上Q_OBJECT关键字,编译项目会提示无法找到moc_XXX.cpp文件. ...
- C++并发编程之std::future
简单地说,std::future 可以用来获取异步任务的结果,因此可以把它当成一种简单的线程间同步的手段.std::future 通常由某个 Provider 创建,你可以把 Provider 想象成 ...
- 借读:分布式锁和双写Redis
本帖最后由 howtodown 于 2016-10-3 16:01 编辑问题导读1.为什么会产生分布式锁?2.使用分布式锁的方法有哪些?3.本文创造的分布式锁的双写Redis框架都包含哪些内容? ...
- Java基础-算术运算符(Arithmetic Operators)
Java基础-算术运算符(Arithmetic Operators) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. Java程序通过运算符实现对数据的处理,Java中的运算符包括: ...
- docker 时区设置
今天查问题的时候发现 在对时间 格式化为 时间戳的时候,time.mktime(time.strptime('20170609-15:00:00','%Y%m%d-%H:%M:%S')) 发现测试环境 ...
- css3 @keyframes用法
使用@keyframes规则,可以创建动画. 在动画的过程中,可以多次更改css样式的设定. 对于指定的变化:发生时用0%,或关键字“from”和“to”,这与0%和100%相同. 0%:开头动画. ...
- 从url到页面加载浏览器做了什么?
从输入url到页面加载发生了什么?1.DNS解析DNS解析是一个递归查询的过程.DNS解析的过程就是寻找哪台机器上有你需要资源的过程,当你在浏览器中输入一个地址时,www.baidu.com.其实不是 ...
- prefab内容分析
写在前面: 当前使用的unity版本:5.3.7p4. 如果打开prefab文件是乱码: 把editer的asset Srialization改为Force Text即可. 一.什么是Prefab P ...
- OpenResty 扩展库(二)lua-resty-template
Lua和OpenResty的模板引擎(HTML) 模板语法 您可以在模板中使用以下标签: {{expression}},写入表达式的结果 - html转义 {*expression*},写入表达结果 ...