QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#494305 | #5006. Heximal | Grunray | TL | 0ms | 3744kb | C++20 | 2.7kb | 2024-07-27 15:08:19 | 2024-07-27 15:08:19 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#define itn int
#define PII pair<int, int>
#define PLI pair<long long, int>
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#include<bits/stdc++.h>
#include<unordered_map>
using ll = long long;
using ldou = long double;
using unll = unsigned long long;
using namespace std;
ll gcd(ll a, ll b) { // 最大公约数
while (b ^= a ^= b ^= a %= b)
;
return a;
}
ll lcm(ll a, ll b) { // 最小公倍数
return a / gcd(a, b) * b;
}
ll qmi(ll m, ll k, ll p) { // 快速幂
// 求 m^k mod p,时间复杂度 O(logk)。
// m为底数,k为幂
ll res = 1 % p, t = m;
while (k) {
if (k & 1) res = res * t % p;
t = t * t % p;
k >>= 1;
}
return res;
}
unll qmi(unll m, unll k, unll p) { //龟速乘
ll res = 0, t = m;
while (k) {
if (k & 1) res = (res + t) % p;
k >>= 1;
t = (t << 1) % p;
}
return res;
}
//////////////////////////////////////////////////////////////////////////////////
unll n, m, k;
const int N = 5e6 + 5;
const ll INF = 4e18;
const ll MODE = ll(998244353);
const unll base = 131;
const unll prime = 233317;
const int dx[4] = { 1,-1, 0, 0 };
const int dy[4] = { 0, 0, 1,-1 };
//priority_queue<unll, vector<unll>, greater<unll> >pq;
string nums;
string s2;
void solve() {
//cin >> nums;
//scanf("%s", nums);
getline(cin, nums);
//k = 1;
int cnt = 0;
int x = 0, y = 0;
while (1) {
y = 0;
int len = nums.length();
s2.resize(len);
for (int i = 0; i < len; i++) {
y *= 10;
s2[i] = (nums[i] - '0' + y) / 6 + '0';
y = (nums[i] - '0' + y) % 6;
/*cout << " i " << i << " " << y << '\n';
cout << " " << nums[i] - '0' + y << '\n';*/
}
//res.push_back(y);
cnt++;
//cout << " y " << y << '\n';
/*if (y < 6 && nums.length() == 1) {
break;
}*/
if (len == 1 && nums[0] - '0' < 6) {
break;
}
x = y;
/*for (int i = 0; i < 30; i++)
cout << s2[i] << ' ';
cout << '\n';*/
int i;
for (i = 0; i < s2.length(); i++)
if (s2[i] != '0')
break;
/*cout << " s2 " << s2 << '\n';
cout << " nums " << nums << '\n';*/
nums = "";
nums.resize(s2.length() - i);
int j = 0;
for (i; i < s2.length(); i++)
nums[j++] = s2[i];
//cout << " ****** \n";
//printf("****\n");
}
printf("%d", cnt);
//cout << /*res.size()*/cnt << '\n';
}
signed main() {
//std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
/*freopen("out.txt", "r", stdin);
freopen("wrt.txt", "w", stdout);*/
int TTT = 1; //cin >> TTT;
while (TTT--) {
solve();
}
/*while (cin >> n >> m) {
solve();
}*/
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
input:
0
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
1865
output:
5
result:
ok single line: '5'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
6
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
5
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
216
output:
4
result:
ok single line: '4'
Test #6:
score: -100
Time Limit Exceeded
input:
659048550435237232393875796171343597297252783860791224966151609834498375660891507785647188078990198766575546966667938541517709208360385263203130845215396367798902376853652489767206051858708602045962531467486884777174160264291462611744982439094276291073422016146183934443085743192727084631329374278797...