QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#158150#7102. Live Loveucup-team1087#AC ✓1ms3908kbC++11800b2023-09-02 16:16:092023-09-02 16:16:43

Judging History

你现在查看的是最新测评结果

  • [2023-09-02 16:16:43]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3908kb
  • [2023-09-02 16:16:09]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int main() {
    int t;
    scanf("%d", &t);
    for (int n, m; t--; ) {
        scanf("%d%d", &n, &m);
        printf("%d ", m);
        if (m == 0) {
            puts("0");
            continue;
        }
        if (((n + 1) >> 1) >= m) {
            puts("1");
            continue;
        }
        if (n == m) {
            printf("%d\n", m);
            continue;
        }
        int l = 0, r = m + 1;
        for (int mid, tmp; l + 1 < r; ) {
            mid = (l + r) >> 1;
            tmp = m / mid * mid + (m / mid - 1);
            if (tmp + (m % mid) + ((bool)(m % mid)) <= n)
                r = mid;
            else
                l = mid;
        }
        printf("%d\n", r);
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3868kb

input:

5
5 4
100 50
252 52
3 0
10 10

output:

4 2
50 1
52 1
0 0
10 10

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3908kb

input:

100
13 3
384 171
94 36
581 70
782 715
651 287
810 789
353 314
2 2
65 47
684 194
242 213
135 42
695 484
512 195
14 0
721 253
665 257
381 78
456 220
1000 500
1000 501
31 31
703 484
137 1
271 55
666 366
966 316
457 248
166 38
716 679
972 258
627 91
380 1
451 436
605 173
987 780
457 180
2 0
718 574
119 ...

output:

3 1
171 1
36 1
70 1
715 11
287 1
789 36
314 8
2 2
47 3
194 1
213 8
42 1
484 3
195 1
0 0
253 1
257 1
78 1
220 1
500 1
501 2
31 31
484 3
1 1
55 1
366 2
316 1
248 2
38 1
679 18
258 1
91 1
1 1
436 28
173 1
780 4
180 1
0 0
574 4
8 1
118 1
126 1
12 2
34 1
381 21
658 4
288 4
161 1
76 1
195 1
646 6
27 1
9 2...

result:

ok 100 lines

Extra Test:

score: 0
Extra Test Passed