CF997C.Sky Full of Stars
省选/NOI-
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
On one of the planets of Solar system, in Atmosphere University, many students are fans of bingo game.
It is well known that one month on this planet consists of n2 days, so calendars, represented as square matrix n by n are extremely popular.
Weather conditions are even more unusual. Due to the unique composition of the atmosphere, when interacting with sunlight, every day sky takes one of three colors: blue, green or red.
To play the bingo, you need to observe the sky for one month — after each day, its cell is painted with the color of the sky in that day, that is, blue, green or red.
At the end of the month, students examine the calendar. If at least one row or column contains only cells of one color, that month is called lucky.
Let's call two colorings of calendar different, if at least one cell has different colors in them. It is easy to see that there are 3n⋅n different colorings. How much of them are lucky? Since this number can be quite large, print it modulo 998244353.
在太阳系的某颗行星上,大气大学(Atmosphere University)的许多学生都是宾果(bingo)游戏的爱好者。
众所周知,该行星上的一个月由 n2 天组成,因此日历通常以 n×n 的方阵形式呈现,极为流行。
天气状况更加奇特。由于大气成分独特,在阳光照射下,每天的天空都会呈现三种颜色之一:蓝色、绿色或红色。
要玩宾果游戏,需连续观测整个月的天空——每天结束后,日历中对应单元格即被涂上当天天空的颜色(即蓝色、绿色或红色)。
一个月结束后,学生们检查该日历。若至少存在一行或一列,其所有单元格均为同一种颜色,则称该月为“幸运月”。
我们称两种日历着色方案不同,当且仅当至少有一个单元格的颜色不同。显然,总共有 3n⋅n 种不同的着色方案。其中有多少种是幸运月?由于该数目可能非常大,请输出其对 998244353 取模的结果。
输入格式
The first and only line of input contains a single integer n (1≤n≤1000000) — the number of rows and columns in the calendar.
输入仅有一行,包含一个整数 n(1≤n≤1000000)—— 表示日历的行数与列数。
输出格式
Print one number — number of lucky colorings of the calendar modulo 998244353
输出一个数字——日历的幸运染色方案数对 998244353 取模的结果
输入输出样例
输入#1
1
输出#1
3
输入#2
2
输出#2
63
输入#3
3
输出#3
9933
说明/提示
In the first sample any coloring is lucky, since the only column contains cells of only one color.
In the second sample, there are a lot of lucky colorings, in particular, the following colorings are lucky:

While these colorings are not lucky:

在第一个样例中,任意染色方案都是幸运的,因为唯一的列中所有格子颜色相同。
在第二个样例中,存在大量幸运染色方案,例如以下染色方案是幸运的:

而以下染色方案则不是幸运的:

输入解题思路,AI测评打分。不知道怎么写?