• AtCoder Beginner Contest 068 D


    D - Decrease (Contestant ver.)


    Time limit : 2sec / Memory limit : 256MB

    Score : 600 points

    Problem Statement

    We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N−1 or smaller.

    • Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.

    It can be proved that the largest element in the sequence becomes N−1 or smaller after a finite number of operations.

    You are given an integer K. Find an integer sequence ai such that the number of times we will perform the above operation is exactly K. It can be shown that there is always such a sequence under the constraints on input and output in this problem.

    Constraints

    • 0≤K≤50×1016

    Input

    Input is given from Standard Input in the following format:

    K
    

    Output

    Print a solution in the following format:

    N
    a1 a2 ... aN
    

    Here, 2≤N≤50 and 0≤ai≤1016+1000 must hold.


    Sample Input 1

    Copy
    0
    

    Sample Output 1

    Copy
    4
    3 3 3 3
    

    Sample Input 2

    Copy
    1
    

    Sample Output 2

    Copy
    3
    1 0 3
    

    Sample Input 3

    Copy
    2
    

    Sample Output 3

    Copy
    2
    2 2
    

    The operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].


    Sample Input 4

    Copy
    3
    

    Sample Output 4

    Copy
    7
    27 0 0 0 0 0 0
    

    Sample Input 5

    Copy
    1234567894848
    

    Sample Output 5

    Copy
    10
    1000 193 256 777 0 1 1192 1234567891011 48 425
       题意:给定一个k判断一个N并且输出N个数使得每次最大的数减去N(进行K次后)最大的数变成N-1
    题解:此题又是会产生多种正确结果,所以可以再题目中寻找规律,首先注意到N得取值范围为2-50,也就是说N不会超过50所以可以把所有接的N
    都看做50,有题意可以没看出其实没经过50次操作其实就是每个数减1(把所有数控制成相等的话)。那么就只要特别处理下50的余数即可。
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        long long k;
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>k;
        long a,b,c;
        a=k/50+50;     //要特别处理的数的大小
        b=k%50;       //要特别处理的数的个数
        c=a-b-1;      //正常相等的个数
        cout<<50<<endl;
        for(int i=0;i<50;i++)
        {
            if(i<b)
            {
                if(i==0)
                cout<<a;
                else
                cout<<" "<<a;
            }
            else
            {
                if(i==0)
                cout<<c;
                else 
                cout<<" "<<c;
            }
        }
        cout<<endl;
        return 0;
    }
    漫天星辰,繁华时下。心中冷淡,一笑奈何。
  • 相关阅读:
    SSIS常用的包—XML任务,SQL分析服务执行DDL和Processing任务
    SQL点滴7—使用SQL Server的attach功能出现错误及解决方法
    SSIS中的容器和数据流—数据目的
    SQL点滴8—the account is currently locked out. The system administrator can unlock it.
    SSIS常用的包—WMI数据读取任务和WMI事件监听任务
    Microsoft SQL Server Integration Service文章总结
    SSIS常用的包—Web服务任务
    SQL点滴6—“微软不认识闰年2月29日”&字符"N"的作用
    SSIS中的容器和数据流—数据源
    YUI Grids实现自定义宽度的Template
  • 原文地址:https://www.cnblogs.com/Scalpel-cold/p/7258479.html
Copyright © 2020-2023  润新知