QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#716347#8758. Menji 和 gcdqikala7777#TL 1954ms3680kbC++23783b2024-11-06 14:59:462024-11-06 14:59:53

Judging History

This is the latest submission verdict.

  • [2024-11-06 14:59:53]
  • Judged
  • Verdict: TL
  • Time: 1954ms
  • Memory: 3680kb
  • [2024-11-06 14:59:46]
  • Submitted

answer

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef tuple<int,LL,LL> TPL;
typedef pair<LL,LL> PII;
const int N=1e6+7,inf=0x3f3f3f3f;const LL Linf=0x3f3f3f3f3f3f3f3fLL;
LL qsm(LL a,LL b,LL p){LL res=1;while(b){if(b&1)res=res*a%p;a=a*a%p;b>>=1;}return res;}
LL lowbit(LL x){return x&-x;}
LL ll,rr;
bool check(LL x){
    LL r1=rr/x,l1=ll/x;
    return r1-l1>1;
}
void solve(){
    cin>>ll>>rr;
    ll--;
    LL l=1,r=rr-ll,ans=0;
    for(LL i=rr-ll;i>=1;i--){
        if(check(i)){
            cout<<i<<endl;
            break;
        }
    }
}
int main(){
   IOS
   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: 1954ms
memory: 3680kb

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: