QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#669358 | #8758. Menji 和 gcd | MIS_T__ | TL | 978ms | 3632kb | C++23 | 429b | 2024-10-23 18:20:16 | 2024-10-23 18:20:16 |
Judging History
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