QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#669358#8758. Menji 和 gcdMIS_T__TL 978ms3632kbC++23429b2024-10-23 18:20:162024-10-23 18:20:16

Judging History

This is the latest submission verdict.

  • [2024-10-23 18:20:16]
  • Judged
  • Verdict: TL
  • Time: 978ms
  • Memory: 3632kb
  • [2024-10-23 18:20:16]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve() {
    i64 L,R;
    cin >> L >> R;
    for ( i64 i = R-L ; i >= 1 ; i-- ) {
        i64 t = (L+i-1)/i;
        if ( L <= t*i && t*i <= R && L <= (t+1)*i && (t+1)*i <= R ) {
            cout << i << '\n';
            return;
        }
    }
}
int main() {
    int T = 1;
    cin >> T;
    while ( T-- ) {
        solve();
    }
}

详细

Test #1:

score: 100
Accepted
time: 978ms
memory: 3632kb

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: