QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#709935 | #8758. Menji 和 gcd | lindongli2004# | WA | 41ms | 3904kb | C++14 | 574b | 2024-11-04 17:31:00 | 2024-11-04 17:31:04 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
int read(){
int x=0,f=1; char ch=getchar();
while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
signed main()
{
int aq=read();
while(aq--){
int L=read(),R=read();
int mx=sqrt(R)+2,ans=1;
for(int d=2;d<=mx;d++){
int Tl=(L-1)/d+1,Tr=R/(d+1);
if(Tl<=Tr)ans=max(ans,Tr);
Tl=(L-1)/d+1; Tr=R/d;
if(Tl<Tr)ans=max(ans,d);
}
printf("%lld\n",ans);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 6ms
memory: 3904kb
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: 41ms
memory: 3848kb
input:
6 357134483534 646200407704 504479652692 514965927651 831245941727 837097365832 778543598197 990152196633 19580905336 99295489037 228262697783 935881261360
output:
215400135901 10299318553 5813176151 198030439326 33098496345 311960420453
result:
wrong answer 5th numbers differ - expected: '49647744518', found: '33098496345'