結果

問題 No.1581 Multiple Sequence
ユーザー tentententen
提出日時 2021-11-29 14:43:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 1,403 bytes
コンパイル時間 2,565 ms
コンパイル使用メモリ 74,236 KB
実行使用メモリ 50,916 KB
最終ジャッジ日時 2023-09-15 07:00:54
合計ジャッジ時間 7,073 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
47,492 KB
testcase_01 AC 40 ms
49,608 KB
testcase_02 AC 187 ms
50,552 KB
testcase_03 AC 205 ms
50,484 KB
testcase_04 AC 84 ms
50,700 KB
testcase_05 AC 212 ms
50,500 KB
testcase_06 AC 112 ms
50,672 KB
testcase_07 AC 80 ms
50,496 KB
testcase_08 AC 94 ms
50,628 KB
testcase_09 AC 195 ms
50,708 KB
testcase_10 AC 138 ms
50,728 KB
testcase_11 AC 64 ms
50,604 KB
testcase_12 AC 101 ms
50,552 KB
testcase_13 AC 43 ms
49,548 KB
testcase_14 AC 205 ms
50,908 KB
testcase_15 AC 155 ms
50,656 KB
testcase_16 AC 69 ms
50,600 KB
testcase_17 AC 226 ms
50,916 KB
testcase_18 AC 60 ms
50,648 KB
testcase_19 AC 183 ms
50,492 KB
testcase_20 AC 189 ms
50,468 KB
testcase_21 AC 204 ms
50,424 KB
testcase_22 AC 127 ms
50,620 KB
testcase_23 AC 233 ms
50,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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];
        dp[0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= Math.sqrt(i); j++) {
                if (i % j != 0) {
                    continue;
                }
                dp[i] += dp[i / j - 1];
                dp[i] %= MOD;
                if (j * j < i) {
                    dp[i] += dp[j - 1];
                    dp[i] %= MOD;
                }
            }
        }
        System.out.println(dp[n]);
    }
}

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 {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0