Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created May 15, 2019 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/687fe6c22d7deb5fd6f7ae175fb3cf29 to your computer and use it in GitHub Desktop.
Save whatalnk/687fe6c22d7deb5fd6f7ae175fb3cf29 to your computer and use it in GitHub Desktop.
AtCoder ABC #099 C - Strange Bank
#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