Created
May 15, 2019 11:28
-
-
Save whatalnk/687fe6c22d7deb5fd6f7ae175fb3cf29 to your computer and use it in GitHub Desktop.
AtCoder ABC #099 C - Strange Bank
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
static int n; | |
int solve(); | |
int solve() { | |
int ans = n; | |
for (int i = 0; i <= n; i++) { | |
int x = 0; | |
int a = i; | |
int b = n - i; | |
while (a > 0) { | |
x += a % 6; | |
a /= 6; | |
} | |
while (b > 0) { | |
x += b % 9; | |
b /= 9; | |
} | |
ans = min(ans, x); | |
} | |
return ans; | |
} | |
int main() { | |
cin >> n; | |
cout << solve() << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment