結果

問題 No.1343 Dividing Digit
ユーザー 遭難者
提出日時 2021-01-16 13:09:09
言語 Java
(openjdk 23)
結果
AC  
実行時間 464 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 6,073 ms
コンパイル使用メモリ 74,780 KB
実行使用メモリ 48,712 KB
最終ジャッジ日時 2024-11-27 13:13:05
合計ジャッジ時間 10,075 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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