QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#494586#5006. HeximalAbclWA 0ms3512kbC++141.6kb2024-07-27 16:15:212024-07-27 16:15:24

Judging History

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

  • [2024-07-27 16:15:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3512kb
  • [2024-07-27 16:15:21]
  • 提交

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 "0";

    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: 0
Wrong Answer
time: 0ms
memory: 3512kb

input:

0

output:

0

result:

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