QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#188511#3421. Reversed Binary Numbersshd_21WA 0ms3964kbC++14960b2023-09-25 21:52:032023-09-25 21:52:04

Judging History

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

  • [2023-09-25 21:52:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3964kb
  • [2023-09-25 21:52:03]
  • 提交

answer

#include<bits/stdc++.h>
#define ll unsigned long long
#define endl '\n'
#define tc() ll t;cin>>t;while(t--)
#define opt() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;

ll decToBin(ll num) {
    ll bin = 0, count=0;
    while(num!=0) {
        ll r = num%2;
        ll t = pow(10, count);
        bin += r*t;
        num/=2;
        count++;
    }
    return bin;
}

ll rev(ll number) {
    ll rev = 0;
    while(number!=0) {
        rev = rev*10+(number%10);
        number/=10;
    }
    return rev;
}

ll binToDec(ll n) {
    ll Num = n;
    ll dec = 0;
    ll base = 1;
    ll temp = n;
    while(temp) {
        ll l = temp%10;
        temp/=10;
        dec += l*base;
        base*=2;
    }
    return dec;
}

int main() {
    opt();

    ll n;
    cin>>n;
    ll temp = decToBin(n);
    ll temp2 = rev(temp);
    ll ans = binToDec(temp2);

    cout<<ans<<endl;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3964kb

input:

37

output:

41

result:

ok single line: '41'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

1

output:

1

result:

ok single line: '1'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3820kb

input:

27494855

output:

1117767

result:

wrong answer 1st lines differ - expected: '29827979', found: '1117767'