QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#722716 | #5117. Find Maximum | TANGTANGCC | WA | 0ms | 3752kb | C++14 | 1.5kb | 2024-11-07 20:01:01 | 2024-11-07 20:01:02 |
Judging History
answer
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define i32 int
#define u32 unsigned int
#define i64 long long
#define u64 unsigned long long
#define u27 __int128
#define endl '\n'
#define VI vector<int>
#define VVI vector<VI>
#define rand() RANDOM(GEN)
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define CTM (cout<<"Time:"<<static_cast<double>(clock()-START_TIME)/CLOCKS_PER_SEC*1000<<"ms"<<endl)
typedef long long ll;
using namespace std;
random_device SEED;
mt19937_64 GEN(SEED());
uniform_int_distribution<u64> RANDOM(0, numeric_limits<u64>::max());
const clock_t START_TIME = clock();
int a[50],b[50];
int calc(int l,int r) {
int x=l,y=r,nb=0;
for (int i = 0; i < 45; ++i) {
a[i]=l%3,b[i]=r%3;
l/=3,r/=3;
}
int ctb;
for (int i = 0; i <= 40; ++i) {
nb+=b[i];
if(b[i]) ctb=i;
}
nb=nb+ctb+1;
if(x==y) return nb;
int ans=nb-1;
int pos;
int f=0,g;
for (int i = 40; i >= 0; --i) {
if(!f and b[i]) f=1,g=i;
pos=i;
if(a[i]!=b[i]) break;
}
for(int i=0;i<pos;i++) {
ans+=2-b[i];
}
return max({ans, nb});
}
signed main() {
#ifndef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
IO;
int tt;
cin>>tt;
while(tt--) {
int l,r;
cin>>l>>r;
cout<<calc(l,r)<<endl;
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3752kb
input:
10 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5
output:
3 4 4 5 4 4 5 4 5 5
result:
wrong answer 2nd numbers differ - expected: '3', found: '4'