Submission #2650185
Source Code Expand
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
std::vector<int64_t> sixs;
std::vector<int64_t> nines;
int solves(int n) {
if (n < 6)
return n;
auto six_itr = std::upper_bound(sixs.begin(), sixs.end(), n);
six_itr--;
auto nine_itr = std::upper_bound(nines.begin(), nines.end(), n);
if (nine_itr == nines.begin())
return solves(n-*six_itr) + 1;
nine_itr--;
return std::min(solves(n-*six_itr), solves(n-*nine_itr)) + 1;
}
int main () {
int n;
std::cin >> n;
for (int i = 0; i < 7; ++i) {
sixs.push_back((int)std::pow(6.0, i));
}
for (int i = 0; i < 6; ++i) {
nines.push_back((int)std::pow(9.0, i));
}
std::cout << solves(n) << std::endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Strange Bank |
| User | wakanapo |
| Language | C++14 (GCC 5.4.1) |
| Score | 300 |
| Code Size | 763 Byte |
| Status | AC |
| Exec Time | 30 ms |
| Memory | 256 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, sample_01.txt, sample_02.txt, sample_03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 10 ms | 256 KiB |
| 02.txt | AC | 30 ms | 256 KiB |
| 03.txt | AC | 7 ms | 256 KiB |
| 04.txt | AC | 2 ms | 256 KiB |
| 05.txt | AC | 5 ms | 256 KiB |
| 06.txt | AC | 1 ms | 256 KiB |
| 07.txt | AC | 1 ms | 256 KiB |
| 08.txt | AC | 1 ms | 256 KiB |
| 09.txt | AC | 1 ms | 256 KiB |
| 10.txt | AC | 1 ms | 256 KiB |
| 11.txt | AC | 7 ms | 256 KiB |
| 12.txt | AC | 2 ms | 256 KiB |
| 13.txt | AC | 2 ms | 256 KiB |
| 14.txt | AC | 1 ms | 256 KiB |
| 15.txt | AC | 1 ms | 256 KiB |
| 16.txt | AC | 15 ms | 256 KiB |
| sample_01.txt | AC | 1 ms | 256 KiB |
| sample_02.txt | AC | 1 ms | 256 KiB |
| sample_03.txt | AC | 7 ms | 256 KiB |