結果
問題 | No.988 N×Mマス計算(総和) |
ユーザー | ks2m |
提出日時 | 2020-02-14 21:31:17 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 632 ms / 2,000 ms |
コード長 | 774 bytes |
コンパイル時間 | 2,420 ms |
コンパイル使用メモリ | 76,900 KB |
実行使用メモリ | 70,040 KB |
最終ジャッジ日時 | 2024-07-06 06:57:57 |
合計ジャッジ時間 | 10,390 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
ソースコード
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 m = sc.nextInt(); int k = sc.nextInt(); String s = sc.next(); long[] b = new long[m]; for (int i = 0; i < b.length; i++) { b[i] = sc.nextLong(); } long[] a = new long[n]; for (int i = 0; i < a.length; i++) { a[i] = sc.nextLong(); } sc.close(); long ans = 0; long suma = 0; for (int i = 0; i < a.length; i++) { suma += a[i]; } long sumb = 0; for (int i = 0; i < b.length; i++) { sumb += b[i]; } suma %= k; sumb %= k; if ("+".equals(s)) { ans = suma * m + sumb * n; } else { ans = suma * sumb; } ans %= k; System.out.println(ans); } }