Luogu P3579 [POI2014]PAN-Solar Panels】的更多相关文章

题目大意: 给出T组询问,每组询问给出四个数a,b,c,d,每次询问满足a<=x<=b,c<=y<=d的gcd(x,y)的最大值 首先可以想到如果存在gcd(x,y)=k,那么就一定要满足b/k>(a-1)/k&&d/k>(c-1)/k. 而n/k的k取法只有√n种,直接枚举即可. //by zykykyk #include<cstdio> #include<ctime> #include<iostream> #inc…
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…
[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…
题目描述 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…
Luogu P3577 [POI2014]TUR-Tourism 题目链接 题目大意:给出一张\(n\)个点,\(m\)条边的无向图,保证任意两点之间没有点数超过\(10\)的简单路径.选择第\(i\)个点要支付\(C_i\)的代价,要求用最小的代价使得每个点被选择或者与一个被选择的点相邻. \(n\leq 20000,m\leq 25000,C_i\leq 1000\). 可以发现,如果原问题是在树上的话就很简单.所以我们先建出\(dfs\)树.因为这是无向图,所以所有的非树边都是返祖边.由题…
二次联通门 : luogu P3567 [POI2014]KUR-Couriers MMP 指针 RE + MLE + WA..... 不得已...向黑恶的数组实力低头 /* 指针 */ #include <algorithm> #include <cstdio> #define Max 2000009 void read (int &now) { now = ; register char word = getchar (); ') word = getchar ();…
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,…
问题相当于找到一个最大的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 题解 容易想到对于\(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&…