問題一覧 > 通常問題

No.3006 Baker's Problem

レベル : / AI推定難易度 : 1500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 51
作問者 : ジュ・ビオレ・グレイス / テスター : 👑 p-adic
お気に入りにしたユーザー ProblemId : 11818 / 自分の提出
問題文最終更新日: 2025-01-11 17:04:52
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 455 (順位表) の他の問題:

Problem Statement

For integers $X_1, Y_1$ given as input, define $X_n, Y_n$ recursively as follows.

$X_{n+1} = X_1X_n - 5Y_1Y_n, \\ Y_{n+1} = X_1Y_n + X_nY_1.$

Find $X_1 + X_2 + \dots + X_N$ and $Y_1 + Y_2 + \dots + Y_N$, each modulo $998244353$.

Input

$X_1 \ Y_1 \ N$

$-10^{18} \leq X_1, Y_1 \leq 10^{18},$
$1 \leq N \leq 10^{18}$

Output

Output $X_1 + X_2 + \dots + X_N$ and $Y_1 + Y_2 + \dots + Y_N$, each modulo $998244353$, separated by a single space. Print a newline at the end.

Sample

Sample 1
Input
1 1 1
Output
1 1

Since $N = 1$, you can simply output $X_1, Y_1$ as they are.

Sample 2
Input
3 1 2
Output
7 7

Since $X_1 = 3, Y_1 = 1$, we have $X_2 = 3 \times 3 - 5 \times 1 \times 1 = 4, \ Y_2 = 3 \times 1 + 3 \times 1 = 6.$
$X_1 + X_2 = 7, \ Y_1 + Y_2 = 7.$

Sample 3
Input
1 -1 9
Output
998241312 755

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