結果
問題 | No.1343 Dividing Digit |
ユーザー |
![]() |
提出日時 | 2021-01-16 13:17:44 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 523 ms / 2,000 ms |
コード長 | 541 bytes |
コンパイル時間 | 1,934 ms |
コンパイル使用メモリ | 74,016 KB |
実行使用メモリ | 48,604 KB |
最終ジャッジ日時 | 2024-11-27 13:31:35 |
合計ジャッジ時間 | 11,962 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } sc.close(); long m = 0; for (int i = 0; i < n; i++) { m += a[i]; } long ans = 0; long ki = 1; for (int i = 0; i < n; i++) { long c = a[n - 1 - i] * ki % m; ans += c; ans %= m; ki *= k; ki %= m; } System.out.println(ans); } }