QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#494588#5006. HeximalAbclTL 0ms3808kbC++141.6kb2024-07-27 16:16:062024-07-27 16:16:06

Judging History

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

  • [2024-07-27 16:16:06]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3808kb
  • [2024-07-27 16:16:06]
  • 提交

answer

#include<bits/stdc++.h>
const int N=1e6+5;
//#define int long long
typedef double db;
typedef long long ll;
using namespace std;
using pii = pair<int,int>;
#define up(i,a,b) for(int i=(a);i<=(b);++i)
#define down(i,a,b) for(int i=(a);i>=(b);--i)
#define puts(a) (cout<<a<<endl)
#define inf (0x7fffffff)
string add(string num1, string num2) {
    if (num1.length() < num2.length())
        swap(num1, num2);
    int up = 0;
    string ans = "";
    int i = num1.length() - 1, j = num2.length() - 1;
    while (i >= 0 || j >= 0 || up > 0) {


        int d1 = i >= 0 ? num1[i--] - '0' : 0;
        int d2 = j >= 0 ? num2[j--] - '0' : 0;

        int sum = d1 + d2 + up;
        ans = to_string(sum % 10) + ans;
        up = sum / 10;
    }

    return ans;
}

string divide(string num, int del) {
    string ans = "";
    int t = 0;
    for (int i = 0; i < num.length(); i++) {
        int d = num[i] - '0';
        t = t * 10 + d;
        ans += to_string(t / del);
        t %= del;
    }
    ans.erase(0, ans.find_first_not_of('0'));
    return ans.empty() ? "0" : ans;
}

string f(string N) {
    if (N == "0" || N == "1") return "1";

    string num = N;
    string log6N = "0";
    string idd = "1";

    while (num != "0") {
        string cl = "0";
        string cp = idd;
        while (num >= cp) {
            cl = add(cl, "1");
            num = divide(num, 6);
        }
        log6N = add(log6N, cl);
        idd = add(idd, "1");
    }
    return log6N;
}

signed main() {
    string N;
    cin >> N;
    string log6N = f(N);
    cout << log6N << endl;
    return 0;
}

详细

Test #1:

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

input:

0

output:

1

result:

ok single line: '1'

Test #2:

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

input:

1865

output:

5

result:

ok single line: '5'

Test #3:

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

input:

6

output:

2

result:

ok single line: '2'

Test #4:

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

input:

5

output:

1

result:

ok single line: '1'

Test #5:

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

input:

216

output:

4

result:

ok single line: '4'

Test #6:

score: -100
Time Limit Exceeded

input:

659048550435237232393875796171343597297252783860791224966151609834498375660891507785647188078990198766575546966667938541517709208360385263203130845215396367798902376853652489767206051858708602045962531467486884777174160264291462611744982439094276291073422016146183934443085743192727084631329374278797...

output:


result: