QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#708757#2933. Sequinary Numeralssefnuray#WA 0ms4000kbC++141.1kb2024-11-04 05:43:282024-11-04 05:43:30

Judging History

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

  • [2024-11-04 05:43:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4000kb
  • [2024-11-04 05:43:28]
  • 提交

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;
        }
    }
    
    

}
    

详细

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'