【bzoj3834】[Poi2014]Solar Panels 数论】的更多相关文章

3834: [Poi2014]Solar Panels Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 367  Solved: 285[Submit][Status][Discuss] Description Having decided to invest in renewable energy, Byteasar started a solar panels factory. It appears that he has hit the go…
题目描述 Having decided to invest in renewable energy, Byteasar started a solar panels factory. It appears that he has hit the gold as within a few days  clients walked through his door. Each client has ordered a single rectangular panel with specified w…
题目描述 Having decided to invest in renewable energy, Byteasar started a solar panels factory. It appears that he has hit the gold as within a few days  clients walked through his door. Each client has ordered a single rectangular panel with specified w…
题目链接 BZOJ3834 题解 容易想到对于\(gcd(x,y) = D\),\(d\)的倍数一定存在于两个区间中 换言之 \[\lfloor \frac{a - 1}{D} \rfloor < \lfloor \frac{b}{D} \rfloor\] \[\lfloor \frac{c - 1}{D} \rfloor < \lfloor \frac{d}{D} \rfloor\] 整除分块即可做到\(O(n\sqrt{max\{b\}})\) #include<algorithm&…
问题相当于找到一个最大的k满足在$[x_1,x_2]$,$[y_1,y_2]$中都有k的倍数 等价于$\frac{x_2}{k}>\frac{x_1-1}{k}$且$\frac{y_2}{k}>\frac{y_1-1}{k}$ 注意到这只有$O(\sqrt{n})$种取值,于是可以分段计算,做到$O(\sqrt{n})$每次询问 #include<cstdio> int T,a,b,c,d,i,j,t; inline void up(int&a,int b){if(a>…
[BZOJ3834][Poi2014]Solar Panels Description Having decided to invest in renewable energy, Byteasar started a solar panels factory. It appears that he has hit the gold as within a few days  clients walked through his door. Each client has ordered a si…
题目大意: $T(T\le1000)$组询问,每次给出$A,B,C,D(A,B,C,D\le10^9)$,求满足$A\le x\le B,C\le y\le D$的最大的$\gcd(x,y)$. 思路: 令$n=\gcd(x,y)$,则若$n$为合法的答案,当且仅当$\lfloor\frac{A-1}n\rfloor<\lfloor\frac Bn\rfloor,\lfloor\frac{C-1}n\rfloor<\lfloor\frac Dn\rfloor$. 考虑数论分块,每次用块内最大值…
http://www.lydsy.com/JudgeOnline/problem.php?id=3834 题意:求$max\{(i,j)\}, smin<=i<=smax, wmin<=i<=wmax$,其中$smin<=smax<=10^9, wmin<=wmax<=10^9$,有$N<=1000$组数据 #include <bits/stdc++.h> using namespace std; int main() { int cs,…
题意 询问两个区间[smin,smax],[wmin,smax]中是否存在k的倍数,使得k最大 分析 将其转化成\([\frac{smin-1}k,\frac{smax}k],[\frac{wmin-1}k,\frac{wmax}k]\) 用分块思想做,注意到这只有\(O(\sqrt{n})\)种取值,于是可以分段计算,做到\(O(\sqrt{n})\)每次询问 我的理解:每一块为[i,j],j=b/(b/i)表示该块的最右端,而i表示该块的最左端,b在[i,j]上的值b/i相同 trick 代…
首先旋转坐标系,将范围表示成矩形或者射线 如果范围是一条线,则将灯按y坐标排序,y坐标相同的按x坐标排序, 对于y相同的灯,f[i]=min(i,它前面灯发光时刻的第k[i]小值), 线段树维护,$O(n\log n)$ 如果范围是一个矩形,则将灯按x坐标排序,x坐标相同的按y坐标排序, 从左往右.从下到上依次扫描,f[i]=min(i,它左下角灯发光时刻的第k[i]小值), 权值线段树套SBT维护,$O(n\log^2n)$ #include<cstdio> #include<algo…