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

直接定义数组长为50,k=0:0,1,2,............49;
k=1:50,0,1,2,3,..............48;
k=2:49,50,1,2,3..............47;
.......
k=50:1,2,3,..............48,49,50;
周期为50
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll n;
ll a[];
int main()
{
scanf("%lld",&n);
for(int i=;i<=;i++)
{
a[i]=n/+i-;
}
n%=;
for(int i=;i<=n;i++)
{
for(int j=;j<=;j++)
{
a[j]--;
}
a[i]+=;
}
printf("50\n");
for(int i=;i<=;i++)
{
if(i!=) printf(" ");
printf("%lld",a[i]);
}
printf("\n");
return ;
}

Atcoder At Beginner Contest 068 D - Decrease (Contestant ver.)的更多相关文章

  1. 【构造】AtCoder Regular Contest 079 D - Decrease (Contestant ver.)

    从n个t变化到n个t-1,恰好要n步,并且其中每一步的max值都>=t,所以把50个49当成最终局面,从这里开始,根据输入的K计算初始局面即可. #include<cstdio> # ...

  2. Atcoder At Beginner Contest 068 C - Cat Snuke and a Voyage

    C - Cat Snuke and a Voyage Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem State ...

  3. AtCoder Beginner Contest 068 ABCD题

    A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...

  4. AtCoder Beginner Contest 068

    A - ABCxxx 题意: 给出n,输出“ABCn”就可以了,纯水题. B - Break Number 题意: 给出n,找出从1到n的闭区间内能够被2整除最多次的数. 思路: 直接模拟. 代码: ...

  5. Atcoder arc079 D Decrease (Contestant ver.) (逆推)

    D - Decrease (Contestant ver.) Time limit : 2sec / Memory limit : 256MB Score : 600 points Problem S ...

  6. Atcoder AtCoder Regular Contest 079 E - Decrease (Judge ver.)

    E - Decrease (Judge ver.) Time limit : 2sec / Memory limit : 256MB Score : 600 points Problem Statem ...

  7. 【贪心】AtCoder Regular Contest 079 E - Decrease (Judge ver.)

    每次将最大的数减到n以下,如此循环直到符合题意. 复杂度大概是n*n*log?(?). #include<cstdio> #include<iostream> #include ...

  8. atcoder beginner contest 251(D-E)

    Tasks - Panasonic Programming Contest 2022(AtCoder Beginner Contest 251)\ D - At Most 3 (Contestant ...

  9. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

随机推荐

  1. [Recompose] Refactor React Render Props to Streaming Props with RxJS and Recompose

    This lesson takes the concept of render props and migrates it over to streaming props by keeping the ...

  2. Web 端 js 导出csv文件

    http://www.qdfuns.com/notes/35821/2ab249182734d1f5c66da6b5cf395db9.html

  3. 关于Echarts表格插件的使用

    <template> <div :style="{height:height,width:width}"></div> </templat ...

  4. 学习推荐《从Excel到Python数据分析进阶指南》高清中文版PDF

    Excel是数据分析中最常用的工具,本书通过Python与Excel的功能对比介绍如何使用Python通过函数式编程完成Excel中的数据处理及分析工作.在Python中pandas库用于数据处理,我 ...

  5. cogs 1405. 中古世界的恶龙[The Drangon of Loowater,UVa 11292]

    1405. 中古世界的恶龙[The Drangon of Loowater,UVa 11292] ★   输入文件:DragonUVa.in   输出文件:DragonUVa.out   简单对比时间 ...

  6. GridControl添加右键菜单

    private void gridView1_MouseDown(object sender, MouseEventArgs e) { GridHitInfo vi = gridView1.CalcH ...

  7. 发送邮件被退回,提示: Helo command rejected: Invalid name 错误

    我自己配置的 postfix + dovecot server, 配置了outlook 后, 相同的账号. 在有的电脑上能收发成功, 在有的电脑上发送邮件就出现退信.提示 Helo command r ...

  8. Objective-C method及相关方法分析

    ## Objective-C method及相关方法分析 转载请注名出处 [http://blog.csdn.net/uxyheaven](http://blog.csdn.net/uxyheaven ...

  9. 高效的TCP数据拆包器

    高效的TCP数据拆包器 接收器,每秒拆1KB的包达到30万以上 /// 数据同步协义数据接收器 /// </summary> /// <remarks> /// 主要功能有 / ...

  10. js---16原型链

    var p = {name:"sss"}; var c2 = Object.create(p,{age:32,salar:"eee"});//c2就继承了p的属 ...