結果
問題 | No.623 fudan no modulus to tigau |
ユーザー |
|
提出日時 | 2017-12-23 00:04:38 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 946 bytes |
コンパイル時間 | 1,964 ms |
コンパイル使用メモリ | 157,932 KB |
実行使用メモリ | 9,552 KB |
最終ジャッジ日時 | 2024-12-17 23:51:37 |
合計ジャッジ時間 | 2,606 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#include<bits/stdc++.h>using namespace std;typedef long long ll;typedef pair<int, int> PII;const int MM = 998244353;const double eps = 1e-8;const int MAXN = 2e6 + 10;int n, m;void prework(){}void read(){}ll t[MAXN], a[MAXN], b[MAXN];ll ans[MAXN];void gao(){ll x;cin >> x;ans[0] = 1;ans[1] = x;for (int i = 2; i <= n; i++){if (t[i] == 1){ans[i] = (ans[a[i]] + ans[b[i]] ) % MM;}else if (t[i] == 2){ans[i] = (a[i] * ans[b[i]]) % MM;}else {ans[i] = (ans[a[i]] * ans[b[i]]) % MM;}}cout << ans[n] << endl;}void solve(int casi){// cout << "Case #" << casi << ": ";cin >> n;for (int i = 2; i <= n; i++)cin >> t[i] >> a[i] >> b[i];cin >> m;for (int i = 1; i <= m; i++)gao();}void printans(){}int main(){// std::ios::sync_with_stdio(false);prework();int T = 1;// cin>>T;for(int i = 1; i <= T; i++){read();solve(i);printans();}return 0;}