QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#227309 | #3421. Reversed Binary Numbers | Bashca# | AC ✓ | 1ms | 3460kb | C++23 | 338b | 2023-10-27 11:59:30 | 2023-10-27 11:59:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int rb(int x) {
vector<int> d;
while (x > 0) {
d.push_back(x % 2);
x /= 2;
}
int ans = 0;
for (int v : d) {
ans = 2 * ans + v;
}
return ans;
}
int main() {
int n;
cin>>n;
cout<<rb(n)<<'\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3388kb
input:
37
output:
41
result:
ok single line: '41'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3428kb
input:
1
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
27494855
output:
29827979
result:
ok single line: '29827979'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3392kb
input:
1000000000
output:
1365623
result:
ok single line: '1365623'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3444kb
input:
999999999
output:
1071961719
result:
ok single line: '1071961719'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3412kb
input:
256
output:
1
result:
ok single line: '1'