QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227309#3421. Reversed Binary NumbersBashca#AC ✓1ms3460kbC++23338b2023-10-27 11:59:302023-10-27 11:59:30

Judging History

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

  • [2023-10-27 11:59:30]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3460kb
  • [2023-10-27 11:59:30]
  • 提交

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'