結果

問題 No.1581 Multiple Sequence
ユーザー tentententen
提出日時 2023-11-27 19:14:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 449 ms / 2,000 ms
コード長 2,062 bytes
コンパイル時間 4,225 ms
コンパイル使用メモリ 89,272 KB
実行使用メモリ 83,676 KB
最終ジャッジ日時 2023-11-27 19:14:58
合計ジャッジ時間 11,280 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
53,992 KB
testcase_01 AC 56 ms
53,968 KB
testcase_02 AC 303 ms
77,892 KB
testcase_03 AC 378 ms
82,480 KB
testcase_04 AC 256 ms
63,972 KB
testcase_05 AC 385 ms
83,328 KB
testcase_06 AC 280 ms
68,228 KB
testcase_07 AC 180 ms
64,656 KB
testcase_08 AC 222 ms
67,188 KB
testcase_09 AC 373 ms
82,488 KB
testcase_10 AC 265 ms
69,232 KB
testcase_11 AC 131 ms
61,548 KB
testcase_12 AC 295 ms
68,072 KB
testcase_13 AC 86 ms
54,912 KB
testcase_14 AC 382 ms
83,232 KB
testcase_15 AC 296 ms
79,280 KB
testcase_16 AC 139 ms
61,516 KB
testcase_17 AC 449 ms
83,444 KB
testcase_18 AC 131 ms
59,160 KB
testcase_19 AC 305 ms
78,048 KB
testcase_20 AC 373 ms
82,232 KB
testcase_21 AC 409 ms
82,448 KB
testcase_22 AC 281 ms
68,444 KB
testcase_23 AC 410 ms
83,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int[] dp = new int[n + 1];
        ArrayList<ArrayList<Integer>> values  = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            values.add(new ArrayList<>());
        }
        dp[0] = 1;
        dp[1] = 1;
        for (int i = 2; i <= n; i++) {
            values.get(i).add(1);
            for (int j = 1; j * i <= n; j++) {
                values.get(i * j).add(i);
            }
            for (int x : values.get(i)) {
                dp[i] += dp[i / x - 1];
                dp[i] %= MOD;
            }
        }
        System.out.println(dp[n]);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0