Problem - 1725C - Codeforces
Problem - 1725C - Codeforces
|
stdfloat | Logout
HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP
Pak Chanek has a mirror in the shape of a circle. There are N lamps on the circumference
numbered from 1 to N in clockwise order. The length of the arc from lamp i to lamp i + 1 is → Virtual participation
Di for 1 ≤ i ≤ N − 1 . Meanwhile, the length of the arc between lamp N and lamp 1 is
DN .
→ Clone Contest to Mashup
Pak Chanek wants to colour the lamps with M different colours. Each lamp can be coloured
with one of the M colours. However, there cannot be three different lamps such that the
colours of the three lamps are the same and the triangle made by considering the three lamps → Submit?
as vertices is a right triangle (triangle with one of its angles being exactly 90 degrees).
Language: GNU G++20 13.2 (64 bit, winlibs)
The following are examples of lamp colouring configurations on the circular mirror.
Choose
Choose File No file chosen
file:
→ Contest materials
Before colouring the lamps, Pak Chanek wants to know the number of distinct colouring
configurations he can make. Count the number of distinct possible lamp colouring
Announcement (en)
configurations, modulo 998 244 353 .
Tutorial (en)
Input
5
The first line contains two integers N and M (1 ≤ N ≤ 3 ⋅ 10 , 2 ≤ M ≤ 3 ⋅ 105 ) — the
number of lamps in the mirror and the number of different colours used.
Output
An integer representing the number of possible lamp colouring configurations, modulo
998 244 353 .
Examples
input Copy
4 2
10 10 6 14
output Copy
10
input Copy
1 2
10
output Copy
Note
In the first example, all correct lamp colouring configurations are [1, 1, 2, 1], [1, 1, 2, 2],
[1, 2, 1, 2], [1, 2, 2, 1], [1, 2, 2, 2], [2, 1, 1, 1], [2, 1, 1, 2], [2, 1, 2, 1], [2, 2, 1, 1], and
[2, 2, 1, 2].
https://mirror.codeforces.com/problemset/problem/1725/C 1/2
5/22/24, 12:19 PM Problem - 1725C - Codeforces
Supported by
https://mirror.codeforces.com/problemset/problem/1725/C 2/2