QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#454732 | #8758. Menji 和 gcd | ntxyl# | TL | 977ms | 3636kb | C++23 | 749b | 2024-06-25 11:59:16 | 2024-06-25 11:59:17 |
Judging History
answer
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
#define int long long
#define all(v) v.begin(), v.end()
//#define x first
//#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
void solve() {
int l , r;
cin >> l >> r;
if(r / 2 >= l){
cout << r / 2 <<endl;
return;
}
int d = r - l;
for(int i = d ;i >= 1 ;i --){
int x = (l + i - 1) / i;
int y = (x + 1) * i;
if(y <= r){
cout<< i << endl;
return;
}
}
}
signed main() {
fastio;
int T;
// T = 1;
cin>>T;
while (T--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 977ms
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