QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#622067 | #8758. Menji 和 gcd | awayyy | TL | 979ms | 3604kb | C++20 | 691b | 2024-10-08 19:43:25 | 2024-10-08 19:43:26 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
using ll = long long;
using ld = double;
const ll mod = 1e9 + 7;
const ll inf = 1e15 + 5;
const int N = 5e6 + 5;
void solve(){
int l,r;
cin>>l>>r;
int num=r-l+1;
while(num){
int n1=r/num;
int n2=n1*num;
if(n2>l){
if(n2-num>=l){
cout<<num<<'\n';
return;
}
}
num--;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
// cout<<fixed<<setprecision(6);
// srand(time(0));
int T = 1;
cin >> T;
while (T--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 979ms
memory: 3604kb
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