結果

問題 No.639 An Ordinary Sequence
ユーザー tentententen
提出日時 2021-11-02 15:08:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 47 ms / 1,000 ms
コード長 1,119 bytes
コンパイル時間 2,227 ms
コンパイル使用メモリ 78,424 KB
実行使用メモリ 37,088 KB
最終ジャッジ日時 2024-04-20 00:12:58
合計ジャッジ時間 3,472 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
36,992 KB
testcase_01 AC 47 ms
36,692 KB
testcase_02 AC 44 ms
36,748 KB
testcase_03 AC 43 ms
36,704 KB
testcase_04 AC 43 ms
36,768 KB
testcase_05 AC 42 ms
36,448 KB
testcase_06 AC 42 ms
36,724 KB
testcase_07 AC 42 ms
36,960 KB
testcase_08 AC 43 ms
36,736 KB
testcase_09 AC 44 ms
36,756 KB
testcase_10 AC 42 ms
36,564 KB
testcase_11 AC 45 ms
36,876 KB
testcase_12 AC 43 ms
37,084 KB
testcase_13 AC 44 ms
36,692 KB
testcase_14 AC 44 ms
36,720 KB
testcase_15 AC 43 ms
36,560 KB
testcase_16 AC 44 ms
36,544 KB
testcase_17 AC 43 ms
36,724 KB
testcase_18 AC 47 ms
37,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 / 3) + dfw(x / 5));
        }
        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 String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0