結果
問題 | No.1336 Union on Blackboard |
ユーザー |
![]() |
提出日時 | 2021-01-15 23:15:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 584 bytes |
コンパイル時間 | 650 ms |
コンパイル使用メモリ | 65,876 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-26 17:26:23 |
合計ジャッジ時間 | 1,591 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 31 |
ソースコード
//順番に依存しないでくれるとラッキー #include <iostream> #define int long long using namespace std; int powmod(int a, int n, int mod) { if (n == 0) return 1; if (n % 2 == 1) return a * powmod(a, n - 1, mod) % mod; return powmod((a * a) % mod, n / 2, mod); } int mod = 1000000007; signed main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[100]; for (int i = 0; i < n; i++) { cin >> a[i]; } int ans = a[0]; for (int i = 1; i < n; i++) { ans = ans * a[i] + ans + a[i]; ans %= mod; } cout << ans << endl; } return 0; }