結果
問題 | No.1081 和の和 |
ユーザー |
![]() |
提出日時 | 2022-09-14 08:37:32 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 1,391 bytes |
コンパイル時間 | 2,270 ms |
コンパイル使用メモリ | 77,448 KB |
実行使用メモリ | 50,520 KB |
最終ジャッジ日時 | 2024-12-14 17:11:08 |
合計ジャッジ時間 | 3,723 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 |
ソースコード
import java.io.*; import java.util.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int[] current = new int[n]; for (int i = 0; i < n; i++) { current[i] = sc.nextInt(); } for (int i = 0; i < n - 1; i++) { int[] next = new int[n - i - 1]; for (int j = 0; j < n - i - 1; j++) { next[j] = (current[j] + current[j + 1]) % MOD; } current = next; } System.out.println(current[0]); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }