Skip to content

Instantly share code, notes, and snippets.

@jwvg0425
Created February 28, 2018 01:31
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 jwvg0425/edaf41c0bc8687fc90abbb1a3ca65db4 to your computer and use it in GitHub Desktop.
Save jwvg0425/edaf41c0bc8687fc90abbb1a3ca65db4 to your computer and use it in GitHub Desktop.
int to_one(int x)
{
if(x==1)
return 0;
int ans = 1 + to_one(x-1); // 1 빼기
if(x%3 == 0)
ans = min(ans, 1 + to_one(x/3));
if(x%2 == 0)
ans = min(ans, 1 + to_one(x/2));
return ans;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment