結果
問題 |
No.623 fudan no modulus to tigau
|
ユーザー |
![]() |
提出日時 | 2018-03-04 04:33:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 619 bytes |
コンパイル時間 | 256 ms |
コンパイル使用メモリ | 23,680 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 23:57:30 |
合計ジャッジ時間 | 850 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf ("%d",&N); | ~~~~~~^~~~~~~~~ main.cpp:10:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | for (int i=2;i<=N;i++) scanf ("%d %d %d",&T[i],&A[i],&B[i]); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:12:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf ("%d",&Q); | ~~~~~~^~~~~~~~~ main.cpp:15:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf ("%lld",&F[1][i]); | ~~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> const long long mod = 998244353; int N,T[55],A[55],B[55]; int Q; long long F[55][55]; int main() { scanf ("%d",&N); for (int i=2;i<=N;i++) scanf ("%d %d %d",&T[i],&A[i],&B[i]); scanf ("%d",&Q); for (int i=0;i<Q;i++){ F[0][i] = 1; scanf ("%lld",&F[1][i]); } for (int i=2;i<=N;i++){ if (T[i] == 1) for(int j=0;j<Q;j++) F[i][j] = (F[A[i]][j] + F[B[i]][j]) % mod; if (T[i] == 2) for(int j=0;j<Q;j++) F[i][j] = (A[i] * F[B[i]][j]) % mod; if (T[i] == 3) for(int j=0;j<Q;j++) F[i][j] = (F[A[i]][j] * F[B[i]][j]) % mod; } for (int i=0;i<Q;i++) printf ("%lld\n",F[N][i]); return 0; }