結果

問題 No.623 fudan no modulus to tigau
ユーザー Sebastian KingSebastian King
提出日時 2017-12-23 00:04:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 946 bytes
コンパイル時間 1,087 ms
コンパイル使用メモリ 144,576 KB
実行使用メモリ 9,604 KB
最終ジャッジ日時 2023-08-22 21:33:10
合計ジャッジ時間 1,871 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,476 KB
testcase_01 AC 3 ms
9,460 KB
testcase_02 AC 3 ms
9,480 KB
testcase_03 AC 3 ms
9,448 KB
testcase_04 AC 3 ms
9,528 KB
testcase_05 AC 3 ms
9,552 KB
testcase_06 AC 3 ms
9,460 KB
testcase_07 AC 3 ms
9,460 KB
testcase_08 AC 3 ms
9,448 KB
testcase_09 AC 3 ms
9,480 KB
testcase_10 AC 3 ms
9,448 KB
testcase_11 AC 3 ms
9,416 KB
testcase_12 AC 3 ms
9,516 KB
testcase_13 AC 3 ms
9,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}

0