QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#391913#5117. Find MaximumwdwWA 1ms3604kbC++202.3kb2024-04-16 21:45:552024-04-16 21:45:55

Judging History

你现在查看的是最新测评结果

  • [2024-04-16 21:45:55]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3604kb
  • [2024-04-16 21:45:55]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
using ll = long long;
using ld = double;
using i64 = int64_t;
const int N = 3e5+5;
const ll mod = 998244353;
const ll inf = 1e18+5;
#define endl '\n'
vector<int>px;
vector<int>a(100);
void solve()
{
    int l,r;
    cin>>l>>r;
    int ans=0;
    if(r<=99){
        for(int i=l;i<=r;i++){
            ans=max(a[i],ans);
        }
        cout<<ans<<endl;
        return;
    }
    int w=3,lx=3,f=1;
    int a1=1,a2=2,a3=1;
    while(lx<=1e18){
        if(lx>=l)ans=max(w,ans);
        if(f==1){
            lx+=a1;
            a1*=3;
            f++;
        }else if(f==2){
            lx+=a2;
            a2*=3;
            f++;
        }else{
            lx+=a3;
            a3*=3;
            f=1;
        }
        w++;
        //  cout<<lx<<" ";
    }
     w=4,lx=4,f=1;
     a1=1,a2=2,a3=1;
    while(lx<=1e18){
        if(lx>=l)ans=max(w,ans);
        if(f==1){
            lx+=a1;
            a1*=3;
            f++;
        }else if(f==2){
            lx+=a2;
            a2*=3;
            f++;
        }else{
            lx+=a3;
            a3*=3;
            f=1;
        }
        w++;
        //  cout<<lx<<" ";
    }
    w=5,lx=5,f=1;
    a1=1,a2=2,a3=1;
    while(lx<=1e18){
        if(lx>=l)ans=max(w,ans);
        if(f==1){
            lx+=a1;
            a1*=3;
            f++;
        }else if(f==2){
            lx+=a2;
            a2*=3;
            f++;
        }else{
            lx+=a3;
            a3*=3;
            f=1;
        }
        w++;
        //  cout<<lx<<" ";
    }
    cout<<ans<<endl;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    cout<<fixed<<setprecision(12);
//    srand(time(NULL));
    int w=2,lx=1,f=1;
    int a1=1,a2=2,a3=1;

    while(lx<=1e18){

        if(f==1){
            lx+=a1;
            a1*=3;
            f++;
        }else if(f==2){
            lx+=a2;
            a2*=3;
            f++;
        }else{
            lx+=a3;
            a3*=3;
            f=1;
        }
        w++;
      //  cout<<lx<<" ";
    }
    px.push_back(2e18);
    int T=1;
    cin >> T;
    while(T--){
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3604kb

input:

10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

output:

0
0
0
0
0
0
0
0
0
0

result:

wrong answer 1st numbers differ - expected: '3', found: '0'