Submission #3808134


Source Code Expand

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            // write your code here
            int N = in.nextInt();
            int ans = N;

            for (int i = 0; i <= N; i++) {
                int min = 0;
                int payBy6 = i;
                while (payBy6 > 0) {
                    min += payBy6 % 6;
                    payBy6 /= 6;
                }
                int payBy9 = N - i;
                while (payBy9 > 0) {
                    min += payBy9 % 9;
                    payBy9 /= 9;
                }
                ans = Math.min(ans, min);
            }

            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Submission Info

Submission Time
Task C - Strange Bank
User hatsujime
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 2021 Byte
Status AC
Exec Time 90 ms
Memory 21460 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 19
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 86 ms 20948 KB
02.txt AC 83 ms 21204 KB
03.txt AC 90 ms 21076 KB
04.txt AC 79 ms 19412 KB
05.txt AC 89 ms 20820 KB
06.txt AC 70 ms 20052 KB
07.txt AC 71 ms 20564 KB
08.txt AC 70 ms 21460 KB
09.txt AC 70 ms 19412 KB
10.txt AC 71 ms 19412 KB
11.txt AC 79 ms 20052 KB
12.txt AC 81 ms 19156 KB
13.txt AC 79 ms 20052 KB
14.txt AC 72 ms 16596 KB
15.txt AC 72 ms 19156 KB
16.txt AC 81 ms 18900 KB
sample_01.txt AC 70 ms 19664 KB
sample_02.txt AC 73 ms 20948 KB
sample_03.txt AC 80 ms 20820 KB