- 博客(27)
- 收藏
- 关注
原创 Ascending Rating【2018 Multi-University Training Contest 3 A题】(单调队列)
Problem Description Before the start of contest, there are n ICPC contestants waiting in a long queue. They are labeled by 1 to n from left to right. It can be easily found that the i-th contestant’s...
2018-07-30 20:52:45 222
原创 【51nod 1222】 最小公倍数计数
**题目来源: Project Euler 基准时间限制:6 秒 空间限制:131072 KB 分值: 640 难度:8级算法题** 定义F(n)表示最小公倍数为n的二元组的数量。 即:如果存在两个数(二元组)X,Y(X <= Y),它们的最小公倍数为N,则F(n)的计数加1。 例如:F(6) = 5,因为[2,3] [1,6] [2,6] [3,6] [6,6]的最小公倍数等于6...
2018-07-30 20:09:32 303
原创 【51nod 1227】 平均最小公倍数(杜教筛)
题目来源: Project Euler 基准时间限制:1.5 秒 空间限制:131072 KB 分值: 640 难度:8级算法题 重点内容 Lcm(a,b)表示a和b的最小公倍数,A(n)表示Lcm(n,i)的平均数(1 <= i <= n), 例如:A(4) = (Lcm(1,4) + Lcm(2,4) + Lcm(3,4) + Lcm(4,4)) / 4 = (4 + 4 +...
2018-07-29 21:07:24 424
原创 【51nod1237】 最大公约数之和 V3 (杜教筛)
基准时间限制:5 秒 空间限制:262144 KB 分值: 640 难度:8级算法题 给出一个数N,输出小于等于N的所有数,两两之间的最大公约数之和。相当于计算这段程序(程序中的gcd(i,j)表示i与j的最大公约数): 由于结果很大,输出Mod 1000000007的结果。G=0; for(i=1;i<=N;i++) for(j=1;j<=N;j++) { ...
2018-07-29 20:03:14 440
原创 【51nod 1238】 最小公倍数之和 V3(杜教筛)
基准时间限制:8 秒 空间限制:262144 KB 分值: 640 难度:8级算法题 收藏 关注 出一个数N,输出小于等于N的所有数,两两之间的最小公倍数之和。相当于计算这段程序(程序中的lcm(i,j)表示i与j的最小公倍数): 由于结果很大,输出Mod 1000000007的结果。G=0; for(i=1;i&amp;amp;amp;amp;amp;amp;amp;lt;=N;i++) for(j=1;j&amp;amp;amp;amp;amp;amp;
2018-07-29 18:22:14 395
原创 Maximum Mode【Nowcoder多校训练第4场G题】(离散化+二分)
来源:牛客网题目描述 The mode of an integer sequence is the value that appears most often. Chiaki has n integersa1,a2,...,ana1,a2,...,an a_1,a_2,...,a_n. She woud like to delete exactly m of them such that:...
2018-07-28 16:59:06 217
原创 【HDU 5608】function(杜教筛)
Problem Description There is a function f(x),which is defined on the natural numbers set N,satisfies the following eqautionN2−3N+2=∑d|Nf(d)N2−3N+2=∑d|Nf(d)N^2−3N+2=\sum_{d|N}f(d)calulate ∑ni=1f(i...
2018-07-27 21:03:18 254
原创 【51nod 1239】 欧拉函数之和(杜教筛)
基准时间限制:3 秒 空间限制:131072 KB 分值: 320 难度:7级算法题 对正整数n,欧拉函数是小于或等于n的数中与n互质的数的数目。此函数以其首名研究者欧拉命名,它又称为Euler’s totient function、φ函数、欧拉商数等。例如:φ(8) = 4(Phi(8) = 4),因为1,3,5,7均和8互质。 S(n) = Phi(1) + Phi(2) + …… Ph...
2018-07-27 18:57:33 366
原创 【51nod 1244】 莫比乌斯函数之和 (杜教筛)
莫比乌斯函数,由德国数学家和天文学家莫比乌斯提出。梅滕斯(Mertens)首先使用μ(n)(miu(n))作为莫比乌斯函数的记号。具体定义如下: 如果一个数包含平方因子,那么miu(n) = 0。例如:miu(4), miu(12), miu(18) = 0。 如果一个数不包含平方因子,并且有k个不同的质因子,那么miu(n) = (-1)^k。例如:miu(2), miu(3), miu(3...
2018-07-27 17:01:38 595
原创 若干式子的证明
一些定理: 1.设f,gf,gf,g为两个数论函数,ttt为完全积性函数,若:f(n)=∑i=1nt(i)g(⌊ni⌋)f(n)=∑i=1nt(i)g(⌊ni⌋)f(n)=\sum_{i=1}^nt(i)g(\lfloor \frac{n}{i}\rfloor) 则:g(n)=∑i=1nμ(i)t(i)f(⌊ni⌋)g(n)=∑i=1nμ(i)t(i)f(⌊ni⌋)g(n)=\sum_{i=1...
2018-07-27 16:10:05 446
原创 Naive Operations【2018 Multi-University Training Contest 2 G题】(线段树)
Problem Description In a galaxy far, far away, there are two integer sequence a and b of length n. b is a static permutation of 1 to n. Initially a is filled with zeroes. There are two kind of oper...
2018-07-26 17:21:25 178
原创 Distinct Values【2018 Multi-University Training Contest 1 D题】(构造)(贪心)
Problem Description Chiaki has an array of n positive integers. You are told some facts about the array: for every two elements ai and aj in the subarray a_l..r(l≤i<j≤r),ai≠ajr(l≤i<j≤r),ai≠ajr ...
2018-07-24 23:52:18 176
原创 关于一些函数求前缀和的问题
1.设f(n)f(n)f(n)为n的因子的和,求: ∑i=1nf(i)∑i=1nf(i)\sum_{i=1}^nf(i) 其中n&amp;amp;lt;1012n&amp;amp;lt;1012nans=∑in∑jn[j|i]∗j=∑jnj∑in[j|i]=∑j=1n⌊nj⌋ans=∑in∑jn[j|i]∗j=∑jnj∑in[j|i]=∑j=1n⌊nj⌋ans=\sum_i^n\sum_j^n[j|i]*j\\=\sum_j...
2018-07-24 20:38:55 409
原创 今天让我们来学一学积性函数的筛法
第一件事情我们要知道的是:积性函数都可以线性筛。(就是说复杂度是O(n)O(n)O(n) 积性函数的性质不说了,在说说常见的几个积性函数。 μ(n)μ(n)\mu(n):莫比乌斯函数 ϕ(n)ϕ(n)\phi(n):欧拉函数 d(n)d(n)d(n):一个数n的约数个数 σ(n)σ(n)σ(n):一个数n的约数和那我们就来筛筛看吧,(注意:所有线性筛积性函数都必须基于线性筛素数。 ...
2018-07-22 18:24:11 432
原创 素数的线性欧拉筛
先上代码:#define maxx 400005using namespace std;int prime[100005];bool p[maxx];int cnt=0;void init(){ for(int i=2;i&amp;lt;maxx;i++) { if(!p[i]) prime[cnt++]=i; ...
2018-07-22 15:10:39 303
原创 今天让我们来学一学杜教筛
终于想起来要学这个了,但是似乎还没学完? 先写一部分那就。注意:在此讨论的函数的定义域均在正整数上讨论 积性函数定义: 设有f(x)f(x)f(x)满足:若p和q为质数p和q为质数p和q为质数 则有f(p∗q)=f(q)∗f(p)f(p∗q)=f(q)∗f(p)f(p*q)=f(q)*f(p) 那么我们称f(x)f(x)f(x)为积性函数。 如: 1.常数函数 l(n)=1l(n...
2018-07-20 20:16:20 1269
原创 【HDU - 1402】A * B Problem Plus (FFT)
Calculate A * B. Input Each line will contain two integers A and B. Process to end of file. Note: the length of each integer will not exceed 50000. Output For each case, output A * B in one li...
2018-07-20 16:18:19 222
原创 Different Integers(Nowcoder多校训练第一场J题)(树状数组+离线)
Given a sequence of integers a 1 , a 2 , …, a n and q pairs of integers (l 1 , r 1 ), (l 2 , r 2 ), …, (l q , r q ), find count(l 1 , r 1 ), count(l 2 , r 2 ), …, count(l q , r q ) where count(i, j) ...
2018-07-19 20:33:54 459
原创 Data Structure? HDU - 4217(树状数组+二分)
Data structure is one of the basic skills for Computer Science students, which is a particular way of storing and organizing data in a computer so that it can be used efficiently. Today let me introdu...
2018-07-18 23:54:20 193
原创 Query on A Tree HDU - 6191 (离线+01字典树合并)
Monkey A lives on a tree, he always plays on this tree. One day, monkey A learned about one of the bit-operations, xor. He was keen of this interesting operation and wanted to practise it at once. ...
2018-07-17 18:41:37 212
原创 Maze HDU - 5094(BFS)
This story happened on the background of Star Trek. Spock, the deputy captain of Starship Enterprise, fell into Klingon’s trick and was held as prisoner on their mother planet Qo’noS. The captain ...
2018-07-16 21:24:46 207
原创 Battle ships HDU - 5093(二分图最大匹配)
Dear contestant, now you are an excellent navy commander, who is responsible of a tough mission currently. Your fleet unfortunately encountered an enemy fleet near the South Pole where the geographi...
2018-07-16 20:18:26 198
原创 Seam Carving HDU - 5092(简单dp)
Fish likes to take photo with his friends. Several days ago, he found that some pictures of him were damaged. The trouble is that there are some seams across the pictures. So he tried to repair these ...
2018-07-16 19:18:27 345
原创 线段树的合并
题目描述: 现在有一棵二叉树,所有非叶子节点都有两个孩子。在每个叶子节点上有一个权值(有n个叶子节点,满足这些权值为1..n的一个排列)。可以任意交换每个非叶子节点的左右孩子。 要求进行一系列交换,使得最终所有叶子节点的权值按照遍历序写出来,逆序对个数最少。 input: 第一行n 下面每行,一个数x 如果x==0,表示这个节点非叶子节点,递归地向下读入其左孩子和右孩子的信息, 如果...
2018-07-15 20:58:42 338
原创 Minimum Inversion Number HDU - 1394(权值线段树)
The inversion number of a given number sequence a1, a2, …, an is the number of pairs (ai, aj) that satisfy i < j and ai > aj. For a given sequence of numbers a1, a2, …, an, if we move the firs...
2018-07-15 19:35:01 238
原创 Xor Sum HDU - 4825(01字典树)
Zeus 和 Prometheus 做了一个游戏,Prometheus 给 Zeus 一个集合,集合中包含了N个正整数,随后 Prometheus 将向 Zeus 发起M次询问,每次询问中包含一个正整数 S ,之后 Zeus 需要在集合当中找出一个正整数 K ,使得 K 与 S 的异或结果最大。Prometheus 为了让 Zeus 看到人类的伟大,随即同意 Zeus 可以向人类求助。你能证明人类...
2018-07-15 15:30:04 132
原创 Law of Commutation HDU - 6189(推导)
As we all know, operation ”+” complies with the commutative law. That is, if we arbitrarily select two integers a and b, a+b always equals to b+a. However, as for exponentiation, such law may be wrong...
2018-07-14 20:37:08 245
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人