QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#695835 | #8758. Menji 和 gcd | qinglu09# | WA | 265ms | 3708kb | C++23 | 1005b | 2024-10-31 20:53:45 | 2024-10-31 20:53:48 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, ll> PLL;
#define endl '\n'
#define rep(i, a, b) for(ll i = (a); i <= (b); i++)
#define per(i, a, b) for(ll i = (a); i >= (b); i--)
#define debug(x) cout<<#x<<": "<<x<<endl
const ll mod=998244353;
const int N=1e5+10;
ll a,b;
ll calc(ll n,ll m)
{
if(n>m) swap(n,m);
ll ans=1;
for(ll l=1,r;l<=n&&l<=1e12;l=r+1)
{
r=min(min(n/(n/l),m/(m/l)),b);
if(b/l-(a-1)/l-1>=1) ans=max(ans,l);
if(b/r-(a-1)/r-1>=1) ans=max(ans,r);
}
return ans;
}
void solve()
{
cin>>a>>b;
cout<<calc(a,b)<<endl;
}
int main()
{
// #ifndef ONLINE_JUDGE
// freopen("test.in","r",stdin);
// freopen("test.out","w",stdout);
// #endif
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
while(T--)
{
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 38ms
memory: 3708kb
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
Wrong Answer
time: 265ms
memory: 3632kb
input:
6 357134483534 646200407704 504479652692 514965927651 831245941727 837097365832 778543598197 990152196633 19580905336 99295489037 228262697783 935881261360
output:
215400135901 10299318553 5813176151 198030439326 19580905336 228262697783
result:
wrong answer 5th numbers differ - expected: '49647744518', found: '19580905336'