QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#826724 | #9075. Bits Reverse | feng_Lrefrain | AC ✓ | 11ms | 3608kb | C++20 | 1.6kb | 2024-12-22 15:41:25 | 2024-12-22 15:41:26 |
Judging History
answer
// https://qoj.ac/contest/1867/problem/9075
/*
* ===============================
* @Author: feng_Lrefrain
* @DateTime: 2024-12-22 15:31:43 CST(UTC+8)
* ===============================
*/
#include <bits/stdc++.h>
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define rep(I,S,N) for(int I=(S);I<(N);++I)
#define per(I,S,N) for(int I=(N)-1;I>=(S);--I)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef double db;
// int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
// inline ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
// inline ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
// inline ll ksm(ll a,ll b,ll p) {ll ans=1;while(b){if(b&1)ans=(ans*a)%p;b>>=1;a=(a*a)%p;}return ans%p;}
// inline ll lowbit(int x) {return x&(-x);}
const int N = 2e5 + 10;
const int M = 998244353, MM = 1e9 + 7, inf = 1e18;
int solve() {
int a, b; cin >> a >> b;
vi aa[2], bb[2];
rep(i, 0, 62) if (a >> i & 1) aa[i & 1].pb(i);
rep(i, 0, 62) if (b >> i & 1) bb[i & 1].pb(i);
if (SZ(aa[0]) != SZ(bb[0]) || SZ(aa[1]) != SZ(bb[1])) {
// cout << "-1\n";
return -1;
}
int ans = 0;
rep(i, 0, SZ(aa[0])) ans += abs(aa[0][i] - bb[0][i]);
rep(i, 0, SZ(aa[1])) ans += abs(aa[1][i] - bb[1][i]);
// cout << (ans >> 2) << '\n';
return ans / 2;
}
/*
*/
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
// cout << fixed << setprecision(6);
int _ = 1;
cin >> _;
rep(i, 1, _ + 1) cout << "Case " << i << ": " << solve() << '\n';
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3608kb
input:
3 0 3 3 6 6 9
output:
Case 1: -1 Case 2: 1 Case 3: 2
result:
ok 9 tokens
Test #2:
score: 0
Accepted
time: 11ms
memory: 3496kb
input:
10000 7710 15375 973222 834469 471452 56651 188265 356262 937670 799667 271275 139758 478003 921397 326270 989759 660733 773404 704847 823278 657246 469149 175141 657754 885471 995694 100976 10574 184105 671365 194858 212648 181670 412313 361081 15451 632193 21228 745707 981594 911635 884353 863600 ...
output:
Case 1: 4 Case 2: 13 Case 3: 12 Case 4: 16 Case 5: 9 Case 6: 11 Case 7: 18 Case 8: 8 Case 9: 17 Case 10: -1 Case 11: 18 Case 12: 14 Case 13: 12 Case 14: 11 Case 15: 12 Case 16: 8 Case 17: 12 Case 18: 10 Case 19: 19 Case 20: -1 Case 21: 11 Case 22: 14 Case 23: 9 Case 24: 6 Case 25: 6 Case 26: 7 Case ...
result:
ok 30000 tokens
Extra Test:
score: 0
Extra Test Passed