QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#391913 | #5117. Find Maximum | wdw | WA | 1ms | 3604kb | C++20 | 2.3kb | 2024-04-16 21:45:55 | 2024-04-16 21:45:55 |
Judging History
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'