# CF1102B Array K-Coloring

1. 每个元素都要被染色
2. 每种颜色都要被使用
3. 每种颜色不会被用于相同的元素(即若颜色$c_i =c_j(i \neq j)$，必须保证$a_i \neq a_j$如果没有可行的方案，输出”NO”,否则输出”YES”和任何一种可行的方案

Code：

# P1025 数的划分

1,1,51,1,5;
1,5,11,5,1;
5,1,15,1,1.

## 输入输出格式

$n,k$($6<n \le 200$,$2 \le k \le 6$)

1个整数，即不同的分法。

1,1,5;
1,2,4;
1,3,3;
2,2,3.

## 题解

$f(x.y) = \Pi_{i=1}^{n}\sum_{j=1}^{n}x^{j}y^{ij}(ij \leq n)$

# [POI2011]LIZ-Lollipop

## 题目描述

Byteasar runs a confectionery in Byteburg.

Strawberry-vanilla flavoured lollipops are the favourite of local children.

These lollipops are composed of multiple segments of the same length, each segment of either strawberry or vanilla flavour.

The price of the lollipop is the sum of the values of its segments, where a vanilla segment costs one bythaler, while a strawberry segments costs two.

Fig. 1: An exemplary lollipop of five segments, three strawberry flavoured and two vanilla, alternately.

The price of this lollipop is 88 bythalers.

Currently Byteasar is left with only one lollipop, though possibly very long.

As a salesman, he knows only too well that probably no one will want to buy the whole lollipop. For this reason he thinks of breaking the lollipop at the joints of the segments in order to get a shorter lollipop. Each fragment for sale, of course, must stay in one piece.

Byteasar vast experience of a salesman, as well as his understanding of children psychology, tell him that his young customers will most likely want to spend all their money on a single lollipop. With this in mind, he wonders for which values of kk the lollipop he has can be broken down in such a way that as a result one would get, among other pieces, a lollipop worth exactly kk bythalers.

Naturally, he is interested in the way of breaking the lollipop as well.

## 输入输出格式

In the first line of the standard input there are two integers nn and mm (1\le n,m \le 1\ 000\ 0001≤n,m≤1 000 000), separated by a single space.

These denote, respectively, the number of segments of the last lollipop left in store, and the number of values of kk to consider.

The lollipop’s segments are numbered from 1 to nn.

The second line gives an nn-letter description of the lollipop, consisting of letters T and W, where T denotes a strawberry flavoured segment, while W - vanilla flavoured;the ii-th of these letters specifies the flavour of the ii-th segment.

In the following mm lines successive values of kk(1\le k\le 2\ 000\ 0001≤k≤2 000 000) to consider are given, one per line.

Your program should print out exactly mm lines, giving, one per line, the results for successive values of kk, to the standard output.

If for a given value of kk it is impossible to break the lollipop in such a way that there is a contiguous fragment worth exactly kk bythalers, then the word NIE (no in Polish) should be printed. Otherwise, two integers ll and rr (1\le l\le r\le n1≤lrn), separated by single spaces, should be printed, such that the fragment of the lollipop composed of the segments numbered from ll to rr inclusively is worth exactly kk bythalers. If there are multiple such pairs, your program is free to choose one arbitrarily.

## 说明

SPJ对于格式的要求较为严格。对于每个询问后，应紧跟一个换行符。在最后一次输出你的答案以及一个换行符后不应有任何输出。

## 题解

$q$与$n$同级，分析（不会，胡乱猜然后发现两边相等）可得$T$应取$\sqrt{nlogn}$

1. 左右都是1，$[L+1,R-1]$即为和它奇偶性相同的前驱。
2. 左或者右有一个2，移出2的区间即为和它奇偶性相同的前驱。
3. 都是2为第二条的平凡情况。