結果

問題 No.1343 Dividing Digit
ユーザー 遭難者遭難者
提出日時 2021-01-16 13:09:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 393 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 74,916 KB
実行使用メモリ 60,904 KB
最終ジャッジ日時 2023-08-18 09:16:16
合計ジャッジ時間 10,988 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
55,752 KB
testcase_01 AC 114 ms
56,324 KB
testcase_02 AC 114 ms
56,188 KB
testcase_03 AC 375 ms
60,680 KB
testcase_04 AC 197 ms
58,920 KB
testcase_05 AC 247 ms
60,288 KB
testcase_06 AC 221 ms
59,764 KB
testcase_07 AC 282 ms
60,556 KB
testcase_08 AC 360 ms
60,604 KB
testcase_09 AC 371 ms
60,636 KB
testcase_10 AC 203 ms
59,596 KB
testcase_11 AC 270 ms
60,408 KB
testcase_12 AC 336 ms
60,580 KB
testcase_13 AC 330 ms
60,828 KB
testcase_14 AC 205 ms
59,124 KB
testcase_15 AC 266 ms
60,724 KB
testcase_16 AC 210 ms
59,416 KB
testcase_17 AC 356 ms
60,728 KB
testcase_18 AC 381 ms
60,904 KB
testcase_19 AC 325 ms
60,724 KB
testcase_20 AC 287 ms
60,432 KB
testcase_21 AC 365 ms
60,764 KB
testcase_22 AC 363 ms
60,456 KB
testcase_23 AC 393 ms
60,900 KB
testcase_24 AC 332 ms
60,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) {
        var sc = new Scanner(System.in);
        var ou = new PrintWriter(System.out);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        long x = 0;
        long y = 0;
        int[] a = new int[n];
        for(int i = 0 ; i < n ; i++) a[i] = Integer.parseInt(sc.next());
        for(int i = 0 ; i < n ; i++) y += a[i];
        for(int i = 0 ; i < n ; i++){
            x *= k;
            x += a[i];
            x %= y;
        }
        ou.println(x % y);
        sc.close();
        ou.flush();
    }
}
0