Submission #3717103
Source Code Expand
import java.util.Map.Entry; import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { FastScanner sc = new FastScanner(System.in); int N = sc.nextInt(); int min = Integer.MAX_VALUE; for(int i = 0; i <= N; i++){ int count = 0; int price6 = i; int price9 = N - i; while(true){ count += price6 % 6; price6 /= 6; if(price6 == 0) break; } while(true){ count += price9 % 9; price9 /= 9; if(price9 == 0) break; } min = Math.min(min, count); } System.out.println(min); } } class FastScanner { private InputStream in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; public FastScanner(InputStream in) { this.in = in; } private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c){ return 33 <= c && c <= 126; } public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next()); } }
Submission Info
Submission Time | |
---|---|
Task | C - Strange Bank |
User | Oland |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 2895 Byte |
Status | AC |
Exec Time | 78 ms |
Memory | 21332 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
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 | 73 ms | 19412 KB |
02.txt | AC | 77 ms | 20692 KB |
03.txt | AC | 75 ms | 18516 KB |
04.txt | AC | 76 ms | 19156 KB |
05.txt | AC | 77 ms | 20692 KB |
06.txt | AC | 69 ms | 19284 KB |
07.txt | AC | 70 ms | 18900 KB |
08.txt | AC | 69 ms | 19156 KB |
09.txt | AC | 71 ms | 20564 KB |
10.txt | AC | 67 ms | 21204 KB |
11.txt | AC | 74 ms | 20564 KB |
12.txt | AC | 77 ms | 18260 KB |
13.txt | AC | 72 ms | 18260 KB |
14.txt | AC | 70 ms | 18004 KB |
15.txt | AC | 69 ms | 20692 KB |
16.txt | AC | 78 ms | 18900 KB |
sample_01.txt | AC | 66 ms | 21332 KB |
sample_02.txt | AC | 68 ms | 20308 KB |
sample_03.txt | AC | 76 ms | 18772 KB |