QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#593785#8758. Menji 和 gcdJinguluWA 58ms3572kbC++14655b2024-09-27 16:00:232024-09-27 16:00:24

Judging History

This is the latest submission verdict.

  • [2024-09-27 16:00:24]
  • Judged
  • Verdict: WA
  • Time: 58ms
  • Memory: 3572kb
  • [2024-09-27 16:00:23]
  • Submitted

answer

#include <iostream>
#define int long long
using namespace std;


int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

signed main(){
    int t;
    cin>>t;
    while(t--){
        int l,r;
        cin>>l>>r;
        int ans=0;
        for(int i=1;i<=1e6;i++){
            int x=l/i;
            int rx=i*x+x;
            if(l%i!=0){
                rx+=x;
            } 
            if(rx<=r){
                ans=max(ans,x);
            }
            x=r/i;
            int lx=x*i-x; 
           
            if(lx>=l){
                ans=max(ans,x);
            }
        }
    cout<<ans<<endl;
    }
    return 0;

}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 58ms
memory: 3572kb

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
9
70
126
1754385
5861340682
7007007007

result:

wrong answer 5th numbers differ - expected: '7', found: '9'