問題一覧 > 通常問題

No.2004 Incremental Coins

レベル : / AI推定難易度 : 2625 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 14
作問者 : 👑 to-omer / テスター : 👑 hamamu ygussany
お気に入りにしたユーザー ProblemId : 7232 / 自分の提出
問題文最終更新日: 2022-07-05 22:14:40
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 351 (順位表) の他の問題:

Problem Statement

There are $N+1$ boxes numbered from $0$ to $N$, and a large number of coins. Initially, box $i$ contains $A_i$ coins. You will now perform the following operation $K$ times.

  • For $j=1,2,...,N$ in this order, put into box $P_j\ (<j)$ as many coins as box $j$ contains.

Find the number of coins in each box after all the operations are finished. Since the number of coins can be very large, find it modulo $998244353$.

Constraints

  • All input values are integers.
  • $1 \le N \le 2\times 10^5$
  • $1 \le K \le 10^{18}$
  • $0 \le A_i < 998244353 \quad (0 \le i \le N)$
  • $0 \le P_j < j \quad (1 \le j \le N)$

Input

$N$ $K$
$A_0$ $A_1$ $...$ $A_N$
$P_1$ $P_2$ $...$ $P_N$

Output

On line $i\ (1\le i\le N+1)$, print the number of coins in box $i-1$ after all the operations are finished.

Sample

Sample 1
Input
3 2
1 1 1 1
0 1 2
Output
4
4
3
1
  • After operation $1$, the boxes contain $2,2,2,1$ coins, respectively.
  • After operation $2$, the boxes contain $4,4,3,1$ coins, respectively.
Sample 2
Input
3 1415926535
8 9 7 9
0 0 0
Output
459611028
9
7
9

Find the values modulo $998244353$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。