結果
| 問題 | No.1343 Dividing Digit |
| コンテスト | |
| ユーザー |
ks2m
|
| 提出日時 | 2021-01-16 13:17:44 |
| 言語 | Java (openjdk 26.0.2.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 330 ms / 2,000 ms |
| + 117µs | |
| コード長 | 541 bytes |
| 記録 | |
| コンパイル時間 | 1,581 ms |
| コンパイル使用メモリ | 85,904 KB |
| 実行使用メモリ | 52,000 KB |
| 最終ジャッジ日時 | 2026-09-30 21:28:09 |
| 合計ジャッジ時間 | 9,370 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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);
}
}
ks2m