# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742045 | t6twotwo | Permutation (APIO22_perm) | C++17 | 32 ms | 4356 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "perm.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<ll, int> mp;
map<ll, int> q;
int solve(ll n) {
if (n == 1) {
return 0;
}
if (mp.count(n)) {
return mp[n];
}
if (n % 2 == 0) {
return mp[n] = solve(n / 2) + 1;
}
mp[n] = solve(n / 2) + 2;
if (n % 3 == 0) {
int x = solve(n / 3) + 2;
if (x < mp[n]) {
mp[n] = x;
q[n] = 1;
}
} else {
int x = solve(n / 3) + 3;
if (x < mp[n]) {
mp[n] = x;
q[n] = 1;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |