Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Days to Eat N Oranges

Minimum Number of Days to Eat N Oranges asks for the fewest days to finish n oranges, choosing each day to eat one, half, or two-thirds when the required divisibility holds.

Statement

You are given an integer n, representing the initial number of oranges you have. Each day, you can choose to perform exactly one of the following actions:

  • Eat 11 orange.

  • If n is divisible by 22, eat n /2/ 2 oranges.

  • If n is divisible by 33, eat 2×(2 \times ( n /3)/ 3) oranges.

Return the minimum number of days required to eat all n oranges.

Constraints:

  • 1≤1 \leq n ≤2×109\leq 2 \times 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Days to Eat N Oranges

Minimum Number of Days to Eat N Oranges asks for the fewest days to finish n oranges, choosing each day to eat one, half, or two-thirds when the required divisibility holds.

Statement

You are given an integer n, representing the initial number of oranges you have. Each day, you can choose to perform exactly one of the following actions:

  • Eat 11 orange.

  • If n is divisible by 22, eat n /2/ 2 oranges.

  • If n is divisible by 33, eat 2×(2 \times ( n /3)/ 3) oranges.

Return the minimum number of days required to eat all n oranges.

Constraints:

  • 1≤1 \leq n ≤2×109\leq 2 \times 10^9