QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#494586 | #5006. Heximal | Abcl | WA | 0ms | 3512kb | C++14 | 1.6kb | 2024-07-27 16:15:21 | 2024-07-27 16:15:24 |
Judging History
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'