結果

問題 No.639 An Ordinary Sequence
ユーザー GrenacheGrenache
提出日時 2018-02-12 12:37:33
言語 Java19
(openjdk 21)
結果
AC  
実行時間 130 ms / 1,000 ms
コード長 769 bytes
コンパイル時間 4,182 ms
コンパイル使用メモリ 73,348 KB
実行使用メモリ 56,212 KB
最終ジャッジ日時 2023-08-30 12:54:37
合計ジャッジ時間 7,051 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,336 KB
testcase_01 AC 127 ms
55,712 KB
testcase_02 AC 126 ms
56,192 KB
testcase_03 AC 126 ms
55,756 KB
testcase_04 AC 125 ms
55,776 KB
testcase_05 AC 124 ms
55,944 KB
testcase_06 AC 125 ms
55,768 KB
testcase_07 AC 126 ms
55,332 KB
testcase_08 AC 124 ms
55,660 KB
testcase_09 AC 127 ms
55,868 KB
testcase_10 AC 125 ms
55,636 KB
testcase_11 AC 126 ms
55,632 KB
testcase_12 AC 129 ms
55,640 KB
testcase_13 AC 129 ms
56,212 KB
testcase_14 AC 130 ms
55,832 KB
testcase_15 AC 127 ms
55,340 KB
testcase_16 AC 128 ms
55,800 KB
testcase_17 AC 124 ms
56,196 KB
testcase_18 AC 127 ms
55,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder639 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		long n = sc.nextLong();

		hm = new HashMap<>();
		hm.put(0L, 1L);

		pr.println(rec(n));
	}

	private static long rec(long n) {
		if (hm.containsKey(n)) {
			return hm.get(n);
		}

		long ret = rec(n / 3) + rec(n / 5);

		hm.put(n, ret);
		return ret;
	}

	private static Map<Long, Long> hm;

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0