E. Kuroni and the Score Distribution妙妙构造证明

Posted Lnn.

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了E. Kuroni and the Score Distribution妙妙构造证明相关的知识,希望对你有一定的参考价值。

前言:这一场,寄!


题目传送门

E. Kuroni and the Score Distribution
  题目类型:数学、证明、贪心构造。
  解析:凭直觉会想到构造1~n的数组,此时三元组最多。感性证明一下:比如1,2,3,4,5,6,7。7 = 1+6 = 2+5 = 3+4。7可以把1-6的所有数都用来构造三元组,每个数都尽量把前面的数用来构造三元组(i-1)/2个,所以这样构造三元组是最多的,这样还不够的话就寄了。
  如果还没构造完就超过了,那么此时需要的数<=(i-1)/2。比如n = 8,构造完1,2,3,4,5,6,7后还想要2个三元组,类比于前面的计算方法,就这样:7+4 = 5+6 = 11,所以构造1,2,3,4,5,6,7,11。如果长度不够就补一些大数。

  code:

void solve()
    ll sum = 0 , now = 1e9 - 5050*5000;
    for(ll i = 1 ; i <= n ; ++i)
        if(sum == m)
            a[i] = now;
            now += 5050;
        else 
            if(sum + (i-1)/2 <= m)
                a[i] = i;
                sum += (i-1)/2;
            else 
                ll cha = m - sum;
                a[i] = i-1 + (i-1-cha*2+1);
                sum = m;
            
        
    
    if(sum < m)
        cout << -1 << endl ;
        return;
    
    for(ll i = 1 ; i <= n ; ++i)
        cout << a[i] << " " ;
    cout << endl ;

以上是关于E. Kuroni and the Score Distribution妙妙构造证明的主要内容,如果未能解决你的问题,请参考以下文章

E. Kuroni and the Score Distribution妙妙构造证明

cf 1305 E. Kuroni and the Score Distribution

cf 1305 E. Kuroni and the Score Distribution

CF1305E Kuroni and the Score Distribution

CF1305E Kuroni and the Score Distribution(构造)

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