結果
問題 | No.639 An Ordinary Sequence |
ユーザー | tenten |
提出日時 | 2022-08-10 18:00:42 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 60 ms / 1,000 ms |
コード長 | 1,138 bytes |
コンパイル時間 | 2,921 ms |
コンパイル使用メモリ | 78,672 KB |
実行使用メモリ | 53,460 KB |
最終ジャッジ日時 | 2023-10-21 03:36:59 |
合計ジャッジ時間 | 5,137 ms |
ジャッジサーバーID (参考情報) |
judge9 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
53,456 KB |
testcase_01 | AC | 58 ms
53,452 KB |
testcase_02 | AC | 56 ms
53,428 KB |
testcase_03 | AC | 57 ms
52,376 KB |
testcase_04 | AC | 56 ms
53,444 KB |
testcase_05 | AC | 57 ms
53,432 KB |
testcase_06 | AC | 57 ms
52,344 KB |
testcase_07 | AC | 57 ms
52,456 KB |
testcase_08 | AC | 57 ms
53,460 KB |
testcase_09 | AC | 56 ms
53,428 KB |
testcase_10 | AC | 56 ms
53,440 KB |
testcase_11 | AC | 56 ms
53,440 KB |
testcase_12 | AC | 56 ms
52,384 KB |
testcase_13 | AC | 57 ms
52,388 KB |
testcase_14 | AC | 58 ms
53,456 KB |
testcase_15 | AC | 57 ms
53,440 KB |
testcase_16 | AC | 58 ms
53,444 KB |
testcase_17 | AC | 58 ms
53,428 KB |
testcase_18 | AC | 59 ms
52,348 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { static HashMap<Long, Long> dp = new HashMap<>(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); dp.put(0L, 1L); System.out.println(dfw(sc.nextLong())); } static long dfw(long x) { if (!dp.containsKey(x)) { dp.put(x, dfw(x / 5) + dfw(x / 3)); } return dp.get(x); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }