2014多校5(1003)hdu4913(线段树区间操作)
2014-08-26 02:49
363 查看
Least common multiple
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 451 Accepted Submission(s): 151
Problem Description
bobo has an integer set S={x1,x2,…,xn}, where xi=2ai * 3bi.
For each non-empty subsets of S, bobo added the LCM (least common multiple) of the subset up. Find the sum of LCM modulo (109+7).
Input
The input consists of several tests. For each tests:
The first line contains n (1≤n≤105). Each of the following n lines contain 2 integers ai,bi (0≤ai,bi≤109).
Output
For each tests:
A single integer, the value of the sum.
Sample Input
2 0 1 1 0 3 1 2 2 1 1 2
Sample Output
11 174
题意:RT
思路:最小公倍数只能是形如2^a * 3^b,而每次求一种最小公倍数 2^i * 3^j 的和只需要考虑小于等于i 和 j 的集合总数就好了,这个计数可以用线段树来完成,按a从小到大的顺
序将b插入线段树(注意b要先离散化),对于相同的a在插入b的时候也要按照b从小到大插入,这是为了保证后面比b大的数还是在a之前插入的,然后可以用两个数组分别维护
小于等于b的集合数 f[o] 和 小于b的集合数 ff[o],然后f[o]-ff[o]就是此时等于b的集合数了,累加就好了,这题也是把我恶心了好久,sad~~
相关文章推荐
- 2014多校10(1003)hdu4973(简单线段树区间操作)
- HDU 4902 Nice boat 2014杭电多校训练赛第四场F题(线段树区间更新)
- 2014北京网络预选赛1008(线段树区间操作)HDU5039
- UVA 11992- Fast Matrix Operations(线段树区间各种操作)
- POJ2528 线段树的区间操作
- POJ 3468 线段树 区间操作 懒惰标记
- [Usaco2008 Nov]lites 开关灯 线段树 区间异或及求和操作
- poj 1436 线段树区间操作 Horizontally Visible Segments
- 线段树(成段更新,区间求和lazy操作 )
- POJ 3468 A Simple Problem with Integers(线段树区间操作)
- ZOJ Monthly, March 2014,3765 Lights (Splay 基本操作,并维护区间上的信息 * 模板)
- 线段树区间维护(各种操作)hdu2871
- coj 1123 带区间操作的线段树(lazy)
- HDU 4869 Turn the pokers (2014多校联合训练第一场1009) 解题报告(维护区间 + 组合数)
- 2014多校3 Wow! Such Sequence!线段树
- poj3225 线段树区间操作 (见鬼)
- POJ 3225 Help with Intervals 线段树区间操作
- 1003 线段树树状数组区间覆盖
- POJ 3225 区间(带标记的线段树区间操作)
- poj 1177 又是一道十分恶心到线段树。 主要是用线段树到区间操作。可以用来节省线性查找的时间。 离散化也十分好的一道题。