CF1725C.Circular Mirror

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Pak Chanek has a mirror in the shape of a circle. There are NN lamps on the circumference numbered from 11 to NN in clockwise order. The length of the arc from lamp ii to lamp i+1i+1 is DiD_i for 1≤i≤N−11 \leq i \leq N-1. Meanwhile, the length of the arc between lamp NN and lamp 11 is DND_N.

Pak Chanek wants to colour the lamps with MM different colours. Each lamp can be coloured with one of the MM 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 as vertices is a right triangle (triangle with one of its angles being exactly 9090 degrees).

The following are examples of lamp colouring configurations on the circular mirror.

Figure 1. an example of an incorrect colouring because lamps 11, 22, and 33 form a right triangle

Figure 2. an example of a correct colouring

Figure 3. an example of a correct colouring

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 configurations, modulo 998 244 353998\,244\,353.

帕克·查内克有一面圆形的镜子。在圆周上按顺时针顺序编号有 NN 盏灯,编号从 11 到 NN。灯 ii 到灯 i+1i+1 之间的圆弧长度为 DiD_i(其中 1≤i≤N−11 \leq i \leq N-1);而灯 NN 与灯 11 之间的圆弧长度为 DND_N。

帕克·查内克希望用 MM 种不同颜色为这些灯染色。每盏灯可被染成 MM 种颜色中的任意一种。但不允许存在三盏互不相同的灯,使得这三盏灯颜色相同,且以这三盏灯为顶点构成的三角形是直角三角形(即其中一个内角恰好为 90∘90^\circ)。

以下是圆形镜子上灯染色方案的一些示例:

图 1:一种错误的染色方案,因为灯 11、22、33 构成一个直角三角形

图 2:一种正确的染色方案

图 3:一种正确的染色方案

在给灯染色之前,帕克·查内克想知道他能构造出多少种不同的染色方案。请计算所有可能的灯染色方案总数,对 998 244 353998\,244\,353 取模。

输入格式

The first line contains two integers NN and MM (1≤N≤3⋅1051 \le N \le 3 \cdot 10^5, 2≤M≤3⋅1052 \le M \le 3 \cdot 10^5) — the number of lamps in the mirror and the number of different colours used.

The second line contains NN integers D1,D2,…,DND_1, D_2, \ldots, D_N (1≤Di≤1091 \le D_i \le 10^9) — the lengths of the arcs between the lamps in the mirror.

第一行包含两个整数 NN 和 MM(1≤N≤3⋅1051 \le N \le 3 \cdot 10^5,2≤M≤3⋅1052 \le M \le 3 \cdot 10^5)—— 分别表示镜中灯的数量以及所使用的不同颜色的数量。

第二行包含 NN 个整数 D1,D2,…,DND_1, D_2, \ldots, D_N(1≤Di≤1091 \le D_i \le 10^9)—— 表示镜中各灯之间弧段的长度。

输出格式

An integer representing the number of possible lamp colouring configurations, modulo 998 244 353998\,244\,353.

一个整数,表示可能的灯颜色配置方案数对 998 244 353998\,244\,353 取模的结果。

输入输出样例

  • 输入#1

    4 2
    10 10 6 14

    输出#1

    10
  • 输入#2

    1 2
    10

    输出#2

    2

说明/提示

In the first example, all correct lamp colouring configurations are [1,1,2,1][1, 1, 2, 1], [1,1,2,2][1, 1, 2, 2], [1,2,1,2][1, 2, 1, 2], [1,2,2,1][1, 2, 2, 1], [1,2,2,2][1, 2, 2, 2], [2,1,1,1][2, 1, 1, 1], [2,1,1,2][2, 1, 1, 2], [2,1,2,1][2, 1, 2, 1], [2,2,1,1][2, 2, 1, 1], and [2,2,1,2][2, 2, 1, 2].

在第一个例子中,所有正确的灯颜色配置为 [1,1,2,1][1, 1, 2, 1]、[1,1,2,2][1, 1, 2, 2]、[1,2,1,2][1, 2, 1, 2]、[1,2,2,1][1, 2, 2, 1]、[1,2,2,2][1, 2, 2, 2]、[2,1,1,1][2, 1, 1, 1]、[2,1,1,2][2, 1, 1, 2]、[2,1,2,1][2, 1, 2, 1]、[2,2,1,1][2, 2, 1, 1] 和 [2,2,1,2][2, 2, 1, 2]。

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

首页