QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#188511 | #3421. Reversed Binary Numbers | shd_21 | WA | 0ms | 3964kb | C++14 | 960b | 2023-09-25 21:52:03 | 2023-09-25 21:52:04 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'