QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#447883#8758. Menji 和 gcdFire_Fly#TL 0ms0kbC++201.4kb2024-06-18 23:24:032024-06-18 23:24:04

Judging History

This is the latest submission verdict.

  • [2024-06-18 23:24:04]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 0kb
  • [2024-06-18 23:24:03]
  • Submitted

answer

//  _____   _   _____    _____   _____   _      __    __
// |  ___| | | |  _  \  | ____| |  ___| | |     \ \  / /
// | |__   | | | |_| |  | |__   | |__   | |      \ \/ /
// |  __|  | | |  _  /  |  __|  |  __|  | |       \  /
// | |     | | | | \ \  | |___  | |     | |___    / /
// |_|     |_| |_|  \_\ |_____| |_|     |_____|  /_/
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define lowbit(i) ((i) & -(i))
#define ull unsigned long long
#define int long long
// #define ll long long
#define Genshin_Impact return
#define Starts 0
#define endl '\n'
using namespace std;
const int mod = 998244353;
const int N = 2e5 + 10;
int a, b;
int ans;
bool check(int i)
{
    int x = ((a + i - 1) / i) * i;
    int y = (b / i) * i;
    return y > x;
}
void js(int l, int r)
{
    if (r < l)
        return;
    int mid = (l + r) >> 1;
    if (mid <= ans)
        return;
    if (check(mid))
    {
        ans = mid;
        js(mid + 1, r);
        return;
    }
    js(l, mid - 1);
    js(mid + 1, r);
}
void Automatic_AC_machine()
{
    cin >> a >> b;
    ans = 1;
    js(1, b - a + 1);
    cout << ans << endl;
    return;
}
signed main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int tt = 1;
    cin >> tt;
    while (tt--)
    {
        Automatic_AC_machine();
    }
    Genshin_Impact Starts;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

10
1 2
2 4
6 10
11 21
147 154
1470 1540
2890 3028
998244353 1000000007
34827364537 41029384775
147147147147 154154154154

output:


result: