Luogu3579 Solar Panels

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Luogu3579 Solar Panels相关的知识,希望对你有一定的参考价值。

?????????math   getch   string   ??????   str       print   ==   min   


???????????????????????????

????????????????????????????????????

??????????????? (p) ?????? ????????? ??? ??????(x, y)??? (a<=x imes p<=b && c<=y imes p <=d)

???(p) ?????? ???

?????? (leftlceildfrac{a}{p} ight ceil <=y <=leftlfloordfrac{b}{p} ight floor)

?????? (leftlceildfrac{c}{p} ight ceil <=y <=leftlfloordfrac{d}{p} ight floor)

?????????????????????????????????

?????? (leftlfloordfrac{a+p-1}{p} ight floor <= leftlfloordfrac{b}{p} ight floor)

?????? (leftlfloordfrac{b+p-1}{p} ight floor <= leftlfloordfrac{d}{p} ight floor)

?????????????????? ???

??????(leftlfloordfrac{a-1}{p} ight floor < leftlfloordfrac{b}{p} ight floor)

??????(leftlfloordfrac{b-1}{p} ight floor < leftlfloordfrac{d}{p} ight floor)

????????????????????? ???????????? (b/p)???(d/p) ???????????????????????? ???????????? (b/p) ??? (d/p)??????????????? (c/p) ??? (d/p)???????????? ?????????????????????

#include<cstdio>
#include<cstring>
#include<algorithm>
#define rd read()
#define R register
using namespace std;

inline int read() {
    int X = 0, p = 1; char c = getchar();
    for (; c > '9' || c < '0'; c =  getchar())
        if (c == '-') p = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        X = X * 10 + c - '0';
    return X * p;
}

inline void cmax(int &A, int B) {
    if (A < B) A = B;
}

inline int cmin(int A, int B) {
    return A > B ? B : A;
}

void work() {
    int ans = 1;
    int a = rd - 1, b = rd, c = rd - 1, d = rd;
    for (R int i = 1, j = 1, up = cmin(b, d); i <= up; i = j + 1) {
        j = cmin(b / (b / i), d / (d / i));
        if (b / j > a / j && d / j > c / j) cmax(ans, j);
    }
    printf("%d
", ans);
}

int main()
{
    int n = rd;
    for (; n; --n) work(); 
}

以上是关于Luogu3579 Solar Panels的主要内容,如果未能解决你的问题,请参考以下文章

POJ-3579 二分答案

drupal7创建自定义的panels布局

有没有办法在 Corona SDK/Solar2D 中在左上角而不是中心渲染精灵?

「Luogu P3302」[SDOI2013]森林

中国剩余定理 hdu 3579

POJ3579 Median —— 二分