結果

問題 No.1343 Dividing Digit
ユーザー tentententen
提出日時 2021-01-18 10:07:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 620 ms / 2,000 ms
コード長 442 bytes
コンパイル時間 2,402 ms
コンパイル使用メモリ 74,256 KB
実行使用メモリ 48,572 KB
最終ジャッジ日時 2024-05-08 00:10:56
合計ジャッジ時間 14,582 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,364 KB
testcase_01 AC 130 ms
41,292 KB
testcase_02 AC 134 ms
41,516 KB
testcase_03 AC 612 ms
48,540 KB
testcase_04 AC 251 ms
46,312 KB
testcase_05 AC 352 ms
48,164 KB
testcase_06 AC 287 ms
47,652 KB
testcase_07 AC 429 ms
47,808 KB
testcase_08 AC 546 ms
48,480 KB
testcase_09 AC 569 ms
48,356 KB
testcase_10 AC 280 ms
47,472 KB
testcase_11 AC 426 ms
48,088 KB
testcase_12 AC 529 ms
48,120 KB
testcase_13 AC 554 ms
48,560 KB
testcase_14 AC 279 ms
47,112 KB
testcase_15 AC 399 ms
48,204 KB
testcase_16 AC 278 ms
47,640 KB
testcase_17 AC 579 ms
48,572 KB
testcase_18 AC 620 ms
48,256 KB
testcase_19 AC 516 ms
48,292 KB
testcase_20 AC 442 ms
48,156 KB
testcase_21 AC 562 ms
48,396 KB
testcase_22 AC 525 ms
48,508 KB
testcase_23 AC 601 ms
48,504 KB
testcase_24 AC 525 ms
48,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] arr = new int[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		    total += arr[i];
		}
		long ans = 0;
		for (int i = 0; i < n; i++) {
		    ans *= k;
		    ans += arr[i];
		    ans %= total;
		}
		System.out.println(ans);
	}
}
0