[Ozon Tech Challenge 2020 (Div.1 + Div.2, Rated]-E. Kuroni and the Score Distribution(构造)

Posted qieqiemin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Ozon Tech Challenge 2020 (Div.1 + Div.2, Rated]-E. Kuroni and the Score Distribution(构造)相关的知识,希望对你有一定的参考价值。

[Ozon Tech Challenge 2020 (Div.1 + Div.2, Rated]-E. Kuroni and the Score Distribution(构造)

Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.

The round consists of nn problems, numbered from 11 to nn. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array a1,a2,…,ana1,a2,…,an, where aiai is the score of ii-th problem.

Kuroni thinks that the score distribution should satisfy the following requirements:

  • The score of each problem should be a positive integer not exceeding 109109.
  • A harder problem should grant a strictly higher score than an easier problem. In other words, 1≤a1<a2<?<an≤1091≤a1<a2<?<an≤109.
  • The balance of the score distribution, defined as the number of triples (i,j,k)(i,j,k) such that 1≤i<j<k≤n1≤i<j<k≤n and ai+aj=akai+aj=ak, should be exactly mm.

Help the team find a score distribution that satisfies Kuroni‘s requirement. In case such a score distribution does not exist, output ?1?1.

Input

The first and single line contains two integers nn and mm (1≤n≤50001≤n≤5000, 0≤m≤1090≤m≤109) — the number of problems and the required balance.

Output

If there is no solution, print a single integer ?1?1.

Otherwise, print a line containing nn integers a1,a2,…,ana1,a2,…,an, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.

Examples

input

Copy

5 3

output

Copy

4 5 9 13 18

input

Copy

8 0

output

Copy

10 11 12 13 14 15 16 17

input

Copy

4 10

output

Copy

-1

Note

In the first example, there are 33 triples (i,j,k)(i,j,k) that contribute to the balance of the score distribution.

  • (1,2,3)(1,2,3)
  • (1,3,4)(1,3,4)
  • (2,4,5)(2,4,5)

题意:

给定一个整数n,以及一个整数m,

让你构造出一个含有n个整数的数组a,使其满足(a_i + a_j = a_k)的点对((i, j, k))个数为m个。

思路:

对于数组中的第k个数(a_k)无论设为何值,满足(a_i + a_j = a_k)的点对((i, j, k))个数最多为(lfloor frac{k-1}{2} floor)

先设(N= lfloor frac{0}{2} floor + lfloor frac{1}{2} floor + dots + lfloor frac{n-1}{2} floor),如果(m>N)那么答案为-1。

再考虑答案存在的情况,

我们需要找到一个下标(k),使其满足(sum_{i = 1}^k lfloor frac{i-1}{2} floor le m < sum_{i = 1}^{k+1} lfloor frac{i-1}{2} floor)

对于(1 leq i leq k)(a_i=i),此时我们满足条件的点对还差(cha=m-sum_{i = 1}^k lfloor frac{i-1}{2} floor)个,

只需要让(a_{k+1}=(a[k] + a[k+1 - cha * 2])) 就恰好有了m个点对。

接下来考虑(k+1<i leq n)(a_i)该填什么数呢?

因为点对我们已经满足了,我们只需要让新填的数不新增出合法点对,且要符合范围(不超过(10^9))。

一个简单的构造方法为:(a_i=a_{i-1}+k+1, (k+1<i leq n))

(x=k+1),那么这样构造后面的(a_i=a_{k+1}+x,a_i=a_{k+1}+2x,a_i=a_{k+1}+3x dots)

因为数组中没出现(x),所以不会有新增的合法点对。

代码:


/*** TEMPLATE CODE * * STARTS HERE ***/
int n;
ll k;
int a[maxn];
ll b[maxn];
void out()
{
    repd(i, 1, n)
    {
        printf("%d%c", a[i], i == n ? '
' : ' ');
    }
}
int main()
{
    //freopen("D:\code\text\input.txt","r",stdin);
    //freopen("D:\code\text\output.txt","w",stdout);
    n = readint();
    k = readll();
    repd(i, 1, n)
    {
        a[i] = i;
        b[i] = (i - 1) / 2;
    }
    ll now = 0ll;
    int flag = 0;
    repd(i, 3, n)
    {
        if (now == k)
        {
            flag = i - 1;
            break;
        }
        if (now + b[i] > k)
        {
            int cha = k - now;
            a[i] = (a[i - 1] + a[i - cha * 2]);
            flag = i;
            break;
        } else
        {
            now += b[i];
        }
    }
    if (!flag)
    {
        if (now == k)
        {
            out();
        } else
        {
            printf("-1
");
        }
    } else
    {
        int x = flag + 1;
        repd(i, flag + 1, n)
        {
            a[i] = a[i - 1] + x;
        }
        out();
    }
    return 0;
}


以上是关于[Ozon Tech Challenge 2020 (Div.1 + Div.2, Rated]-E. Kuroni and the Score Distribution(构造)的主要内容,如果未能解决你的问题,请参考以下文章

Ozon Tech Challenge 2020 游戏存档

Ozon Tech Challenge 2020 (Div.1 + Div.2, Rated, T-shirts + prizes!)

Ozon Tech Challenge 2020 C. Kuroni and Impossible Calculation 模数

[Ozon Tech Challenge 2020 (Div.1 + Div.2, Rated]-E. Kuroni and the Score Distribution(构造)

Ozon Tech Challenge 2020 (Div.1 + Div.2, Rated, T-shirts + prizes!)

Ozon Tech Challenge 2020 (Div.1 + Div.2, Rated, T-shirts + prizes!)E(构造)