BZOJ3542:DZY Loves March】的更多相关文章

询问是要求 $\sum_{i=1}^n((x[i]-a)^2+(y[i]-b)^2)(x[i]=a||y[i]=b)$ 即求 $\sum_{i=1}^n(x[i]-a)^2(y[i]=b)+\sum_{i=1}^n(y[i]-b)^2(x[i]=a)$ 拆开得 $\sum_{i=1}^n(x[i]^2-2ax[i]+a^2)(y[i]=b)+\sum_{i=1}^n(y[i]^2-2by[i]+b^2)(x[i]=a)$ 所以只要算出编号在区间[l,r]中x[i]=a的所有点的个数.y的和.y的…
题目链接 BZOJ3542 题解 线段树裸题,,对每一行每一列开线段树 由于坐标很大,用\(map\)维护根下标 化一下式子,只用维护区间和,区间平方和,区间存在的个数 #include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<map> #define Redge(u) for (int k =…
题意 \(m * m\)的网格,有\(n\)个点.\(t\)个询问:操作一:第\(x\)个点向四个方向移动了\(d\)个单位.操作二:询问同行同列其他点到这个点的曼哈顿距离和.强制在线.(\(n \le 10^5,m \le 10^{18}\)) 分析 没啥好分析的,就是推一下能推出每行每列的一个式子来,然后套两个区间维护的结构就行了. 题解 set + 线段树 #include <bits/stdc++.h> using namespace std; typedef long long ll…
Description 对于正整数n,定义f(n)为n所含质因子的最大幂指数.例如f(1960)=f(2^3 * 5^1 * 7^2)=3, f(10007)=1, f(1)=0. 给定正整数a,b,求sigma(sigma(f(gcd(i,j)))) (i=1..a, j=1..b). Input 第一行一个数T,表示询问数. 接下来T行,每行两个数a,b,表示一个询问. Output 对于每一个询问,输出一行一个非负整数作为回答. Sample Input 4 10000 7558588 9…
传送门 Sol 好神仙的题目.. 一开始就直接莫比乌斯反演然后就 \(GG\) 了 orz 题解 permui 枚举 \(n\),就是求 \(\sum_{i=1}^{n}S(i,m)\) 其中\(S(n,m)=\sum _{i=1}^m\varphi (ni)\) 设 \(n=\prod_{i}p_i^{c_i}\) 设 \(y=\prod _{i=1} p_i^{c_i-1}\),\(w=\prod _{i=1}p_j\) 那么 \[ \begin{aligned} S(n,m)&=y\sum…
(14.10.28改) 本来只想写BZOJ3739:DZY Loves Math VIII的,不过因为和VI有关系,而且也没别人写过VI的题解,那么写下. 不过我还不会插公式…… http://www.lydsy.com/JudgeOnline/problem.php?id=3561 想想还是要把代码放一下的,不然可能一辈子都不会写了= = 为什么那么像FancyCoder写的呢……因为这题本来就是他教我哒……读入优化快速筛甚至快速幂的模板都是他的= = 额Mobius反演系列问题的入门也是看J…
题目链接: DZY Loves Partition Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 323    Accepted Submission(s): 127 Problem Description DZY loves partitioning numbers. He wants to know whether it is…
题目:DZY Loves Fibonacci Numbers 题意比較简单,不解释了. 尽管官方的题解也是用线段树,但还利用了二次剩余. 可是我没有想到二次剩余,然后写了个感觉非常复杂度的线段树,还是mark一下吧. 我是这样考虑这个问题的,首先准备三个数组F,G,K,功能后面解释. 然后对它们有这样一个计算: F[0] = G[0] = 0; F[1] = 1; G[1] = 0; K[0] = 1; K[1] = 0; for(int i=2; i<N; i++){ F[i] = (F[i-…
DZY Loves Chemistry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves chemistry, and he enjoys mixing chemicals. DZY has n chemicals, and m pairs of them will react. He wants to pou…
DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m columns. Some cells of the ches…
A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m columns. Some cells of the c…
DZY Loves Sorting Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 294    Accepted Submission(s): 77 Problem Description DZY has a sequence a[1..n]. It is a permutation of integers 1∼n. Now he…
C. DZY Loves Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY has a sequence a, consisting of n integers. We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment…
B. DZY Loves Chemistry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves chemistry, and he enjoys mixing chemicals. DZY has n chemicals, and m pairs of them will react. He wants to…
C. DZY Loves Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of n units (they…
3309: DZY Loves Math Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 761  Solved: 401[Submit][Status][Discuss] Description 对于正整数n,定义f(n)为n所含质因子的最大幂指数.例如f(1960)=f(2^3 * 5^1 * 7^2)=3, f(10007)=1, f(1)=0.给定正整数a,b,求sigma(sigma(f(gcd(i,j)))) (i=1..a, j=1.…
题目链接: 传送门 DZY Loves Chemistry time limit per test1 second     memory limit per test256 megabytes Description DZY loves Physics, and he enjoys calculating density. Almost everything has density, even a graph. We define the density of a non-directed gr…
题目链接: 传送门 DZY Loves Chemistry time limit per test:1 second     memory limit per test:256 megabytes Description DZY loves chemistry, and he enjoys mixing chemicals. DZY has n chemicals, and m pairs of them will react. He wants to pour these chemicals…
[UOJ#12][UER #1]猜数 试题描述 这一天,小Y.小D.小C正在愉快地玩耍. 小Y是个数学家,他一拍脑袋冒出了一个神奇的完全平方数 n. 小D是个机灵鬼,很快从小Y嘴里套出了 n的值.然后在脑内把 n写成了 a×b的形式.其中 a,b 都是正整数. 小C是个八卦狂,他发现小D从小Y那里获知了神奇的东西,于是死缠烂打追问小D.最后小D说道:“我可以告诉你正整数 g和 l的值,我保证 ab=gl=n且 a,b都是 g 的倍数.但是 a,b 我可不能告诉你.” 这可急坏了小C.他决定退而求…
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation F1 = 1; F2 = 1; Fn = Fn - 1 + Fn - 2 (n > 2). DZY loves Fibonacci numbers very much. Today DZY gives you an array consisting of n integers: a1, a2, ...,…
题目链接: http://codeforces.com/problemset/problem/444/C J. DZY Loves Colors time limit per test:2 secondsmemory limit per test:256 megabytes 问题描述 DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of…
题目大意:Codeforces 444C DZY Loves Colors 题目大意:两种操作,1是改动区间上l到r上面德值为x,2是询问l到r区间总的改动值. 解题思路:线段树模板题. #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> using namespace std; const int maxn = 5*1e5; typedef long lo…
3309: DZY Loves Math Description 对于正整数n,定义f(n)为n所含质因子的最大幂指数.例如f(1960)=f(2^3 * 5^1 * 7^2)=3, f(10007)=1, f(1)=0. 给定正整数a,b,求sigma(sigma(f(gcd(i,j)))) (i=1..a, j=1..b). Input 第一行一个数T,表示询问数. 接下来T行,每行两个数a,b,表示一个询问. Output 对于每一个询问,输出一行一个非负整数作为回答. Sample In…
C. DZY Loves Fibonacci Numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation F1 = 1; F2 …
Description 神校XJ之学霸兮,Dzy皇考曰JC. 摄提贞于孟陬兮,惟庚寅Dzy以降. 纷Dzy既有此内美兮,又重之以修能. 遂降临于OI界,欲以神力而凌♂辱众生. 今Dzy有一魞歄图,其上有\(N\)座祭坛,又有\(M\)条膴蠁边. 时而Dzy狂WA而怒发冲冠,神力外溢,遂有\(K\)条膴蠁边灰飞烟灭. 而后俟其日A50题则又令其复原.(可视为立即复原) 然若有祭坛无法相互到达,Dzy之神力便会大减,于是欲知其是否连通. Input 第一行\(N,M\). 接下来\(M\)行\(x,…
C. DZY Loves Fibonacci Numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation F1 = 1; F2 …
A. DZY Loves Physics time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves Physics, and he enjoys calculating density. Almost everything has density, even a graph. We define the density…
题目地址:http://codeforces.com/contest/447/problem/C C. DZY Loves Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY has a sequence a, consisting of n integers. We'll call a sequence…
參考:http://www.cnblogs.com/chanme/p/3843859.html 然后我看到在别人的AC的方法里还有这么一种神方法,他预先设定了一个阈值K,当当前的更新操作数j<K的时候,它就用一个类似于树状数组段更的方法,用一个 d数组去存内容,譬如它要在区间 [3,6]上加一段fibonacci 原来: id 0 1 2 3 4 5 6 7 8 9 10 d  0 0 0 0 0 0 0 0 0 0 0 更新: id 0 1 2 3 4 5 6  7  8  9 10 d  0…
B. DZY Loves FFT time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves Fast Fourier Transformation, and he enjoys using it. Fast Fourier Transformation is an algorithm used to calculate…