結果
問題 |
No.1791 Repeat Multiplication
|
ユーザー |
![]() |
提出日時 | 2021-11-21 15:39:06 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 880 ms / 3,000 ms |
コード長 | 598 bytes |
コンパイル時間 | 2,654 ms |
コンパイル使用メモリ | 74,516 KB |
実行使用メモリ | 81,224 KB |
最終ジャッジ日時 | 2024-09-15 14:51:27 |
合計ジャッジ時間 | 27,312 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
import java.util.Scanner; import java.io.PrintWriter; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); 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(); pw.println(dp[x]*sum[N/x]); } sc.close(); pw.flush(); } }