QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#708757 | #2933. Sequinary Numerals | sefnuray# | WA | 0ms | 4000kb | C++14 | 1.1kb | 2024-11-04 05:43:28 | 2024-11-04 05:43:30 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <bitset>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>
#include <stdexcept>
#include <utility>
#include <deque>
using namespace std;
typedef long long ll;
typedef long double ld;
int gcd (int a, int b) {
return b ? gcd (b, a % b) : a;
}
int main() {
//these first two lines speed up input / output significantly
ios_base::sync_with_stdio(0);
cin.tie(0);
string seq;
cin>>seq;
if(seq.size()!= 0 ) {
int denPow = seq.size()-1;
ll num = 0;
ll den = pow(2, denPow);
for(int i = 0; i<seq.size(); i++) {
int d = (seq[denPow-i]-'0');
num+= d*(pow(3, i))*(pow(2, denPow-i));
}
ll whole = num/den;
num = num%den;
ll divis = gcd(num, den);
num /= divis;
den /= divis;
if(num!= 0) {
cout<<whole<<" "<<num<<"/"<<den;
} else {
cout<<whole;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3744kb
input:
2101
output:
10
result:
ok single line: '10'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
201
output:
5 1/2
result:
ok single line: '5 1/2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
2010211122112221202012
output:
16541 873801/1048576
result:
ok single line: '16541 873801/1048576'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 4000kb
input:
22222222222222222222222222222222
output:
1725755 -572407425/-1073741824
result:
wrong answer 1st lines differ - expected: '1725755 572407425/1073741824', found: '1725755 -572407425/-1073741824'