QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#604354#8758. Menji 和 gcdUESTC_NLNS#TL 1955ms3636kbC++14409b2024-10-02 10:14:522024-10-02 10:14:52

Judging History

This is the latest submission verdict.

  • [2024-10-02 10:14:52]
  • Judged
  • Verdict: TL
  • Time: 1955ms
  • Memory: 3636kb
  • [2024-10-02 10:14:52]
  • Submitted

answer

#include <iostream>

using namespace std;
using ll = long long;
ll solve() {
    ll l, r;
    cin >> l >> r;
    if (r / 2 >= l) return r / 2;

    ll d = r - l;
    for (;; d--) {
        if (r / d >= (l - 1) / d + 2) return d;
    }
    return 1;
}

int main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
    int t;
    cin >> t;
    while (t--) cout << solve() << '\n';
}

詳細信息

Test #1:

score: 100
Accepted
time: 1955ms
memory: 3636kb

input:

10
1 2
2 4
6 10
11 21
147 154
1470 1540
2890 3028
998244353 1000000007
34827364537 41029384775
147147147147 154154154154

output:

1
2
3
7
7
70
126
1754385
5861340682
7007007007

result:

ok 10 numbers

Test #2:

score: -100
Time Limit Exceeded

input:

6
357134483534 646200407704
504479652692 514965927651
831245941727 837097365832
778543598197 990152196633
19580905336 99295489037
228262697783 935881261360

output:


result: