結果
| 問題 | No.1791 Repeat Multiplication | 
| コンテスト | |
| ユーザー |  ripity | 
| 提出日時 | 2021-11-21 15:35:32 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,318 ms / 3,000 ms | 
| コード長 | 516 bytes | 
| コンパイル時間 | 2,313 ms | 
| コンパイル使用メモリ | 73,508 KB | 
| 実行使用メモリ | 87,232 KB | 
| 最終ジャッジ日時 | 2024-09-15 14:52:10 | 
| 合計ジャッジ時間 | 37,136 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 32 | 
ソースコード
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		long[] dp = new long[N+1];
		long[] sum = new long[N+1];
		dp[1] = 1;
		for( int i = 1; i <= N; i++ ) {
			sum[i] = dp[i]+sum[i-1];
			for( int j = 2; i*j <= N; j++ ) {
				dp[i*j] += dp[i];
			}
		}
		
		for( int i = 0; i < Q; i++ ) {
		    int x = sc.nextInt();
			System.out.println(dp[x]*sum[N/x]);
		}
		
		sc.close();
		
	}
	
}
            
            
            
        