QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695650#8758. Menji 和 gcdhhdhh#TL 978ms3624kbC++23766b2024-10-31 20:31:192024-10-31 20:31:20

Judging History

This is the latest submission verdict.

  • [2024-10-31 20:31:20]
  • Judged
  • Verdict: TL
  • Time: 978ms
  • Memory: 3624kb
  • [2024-10-31 20:31:19]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define debug(x) cout<<#x<<" :"<<x<<endl;
// #define endl '\n'
typedef long long LL;
const int N=1e5+10;
LL a,b;
int op(LL x)
{
    LL p=b/x*x;
    if(p<=b&&p>=a&&p-x>=a&&p-x<=b)
        return 1;
    return 0;
}
void slove()
{
    cin>>a>>b;
    LL o=b-a;
    while(1)
    {
        if(op(o))
        {
            cout<<o<<endl;
            return;
        }
        o--;
    }

}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    int t=1;
     cin>>t;
    while(t--)
    {
        slove();
    }
    return 0;
}


详细

Test #1:

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

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: