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. luogu1941 [NOIp2014]飞扬的小鸟 (dp)

    设f[i][j]为到达(i,j)这个位置的最小操作数 就有$f[i][j]=min\{f[i-1][j+Y[i-1]],f[i-1][j-X[i-1]*k]+k\}$ 然后考虑优化一下转移: 对于一系 ...

  2. 【uoj35】 后缀排序

    http://uoj.ac/problem/35 (题目链接) 题意 如题,并且求height数组. Solution 挂一发后缀自动机构后缀数组及height数组 细节 注意基数排序和连边的时候不要 ...

  3. 【uoj428】普通的计数题

    Portal --> uoj428 Solution 不会胖子的一个log正解qwq只能怂怂滴写分治了qwq ​ 首先就是一个我想不到的转化qwq ​ 我们将第\(i\)次操作加入的数看成一个编 ...

  4. 【CF437C】The Child and Toy

    题目大意:给定一个有 N 个点,M 条边的无向图,点有点权,删除一个点就要付出所有与之有联系且没有被删除的点的点权之和的代价,求将所有点删除的最小代价是多少. 题解:从图连通性的角度出发,删除所有点就 ...

  5. 关闭ubuntu dash 方法

    因为ubuntu默认的sh是连接到dash的,又因为dash跟bash的不兼容所以出错了.执行时可以把sh换成bash 文件名.sh来执行.成功.dash是什么东西,查了一下,应该也是一种shell, ...

  6. logstash marking url as dead 问题解决

    具体问题如下图所示: 将 INFO 信息打印大致如下所示: [2018-03-05T16:26:08,711][INFO ][logstash.setting.writabledirectory] C ...

  7. Scala进阶之路-Scala的基本语法

    Scala进阶之路-Scala的基本语法 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.函数式编程初体验Spark-Shell之WordCount var arr=Array( ...

  8. Python基础【day03】:文件操作(六)

    一.概述 我们工作中需要经常操作文件,下面就讲讲如何用Python操作文件 1.文件操作的流程: 打开文件,得到文件句柄赋值给一个变量 通过文件句柄,对文件进行操作 关闭文件 二.入门 1.语法 op ...

  9. SSIS系列文章收藏

    http://blog.csdn.net/kk185800961/article/details/12398667 https://wenku.baidu.com/view/d16105abdd338 ...

  10. sh脚本学习之: 命令处理

    输出 默认是命令行输出 > 替换输出 >> append输出 2>  错误输出 < 由文件输入 <<eof 控制台输入,eof为输入结束标志 /dev/nul ...