Atcoder At Beginner Contest 068 D - Decrease (Contestant ver.)
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
0
Sample Output 1
4
3 3 3 3
Sample Input 2
1
Sample Output 2
3
1 0 3
Sample Input 3
2
Sample Output 3
2
2 2
The operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].
Sample Input 4
3
Sample Output 4
7
27 0 0 0 0 0 0
Sample Input 5
1234567894848
Sample Output 5
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.)的更多相关文章
- 【构造】AtCoder Regular Contest 079 D - Decrease (Contestant ver.)
从n个t变化到n个t-1,恰好要n步,并且其中每一步的max值都>=t,所以把50个49当成最终局面,从这里开始,根据输入的K计算初始局面即可. #include<cstdio> # ...
- 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 ...
- AtCoder Beginner Contest 068 ABCD题
A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...
- AtCoder Beginner Contest 068
A - ABCxxx 题意: 给出n,输出“ABCn”就可以了,纯水题. B - Break Number 题意: 给出n,找出从1到n的闭区间内能够被2整除最多次的数. 思路: 直接模拟. 代码: ...
- Atcoder arc079 D Decrease (Contestant ver.) (逆推)
D - Decrease (Contestant ver.) Time limit : 2sec / Memory limit : 256MB Score : 600 points Problem S ...
- Atcoder AtCoder Regular Contest 079 E - Decrease (Judge ver.)
E - Decrease (Judge ver.) Time limit : 2sec / Memory limit : 256MB Score : 600 points Problem Statem ...
- 【贪心】AtCoder Regular Contest 079 E - Decrease (Judge ver.)
每次将最大的数减到n以下,如此循环直到符合题意. 复杂度大概是n*n*log?(?). #include<cstdio> #include<iostream> #include ...
- atcoder beginner contest 251(D-E)
Tasks - Panasonic Programming Contest 2022(AtCoder Beginner Contest 251)\ D - At Most 3 (Contestant ...
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
随机推荐
- Android带索引联系人列表
网上Android联系人列表的样例也非常多,都和微信的联系人差点儿相同,因为项目用到了联系人列表索引功能(产品把字母item给去掉了),只是也还是好实现.这里我也来分享分享我的实现,免得以后忘了.那先 ...
- JVM调优系列:(四)GC垃圾回收
跟踪收集算法: 复制(copying): 将堆内分成两个同样空间,从根(ThreadLocal的对象.静态对象)開始訪问每个关联的活跃对象,将空间A的活跃对象所有拷贝到空间B,然后一次性回收整个空间A ...
- tp5项目搭建思路
按照需求,创建主体的目录结构,一般包括管理后台admin,前台展示index,app接口api. admin中又包含controller,model,view,其他等等. 一些js,css,image ...
- 图解RHEL6从安装光盘中进行yum安装
图解RHEL6从安装光盘中进行yum安装 导读:我们这里讲的Yum,是Yellow dog Updater, Modified的缩写,可执行程序名为yum,它的理念是使用一个中心仓库(reposito ...
- jquery中prop()方法和attr()方法
接着上一篇笔记的疑惑,找了下prop()方法和attr()方法的区别. 原来query1.6中新加了一个方法prop(),一直没用过它,官方解释只有一句话:获取在匹配的元素集中的第一个元素的属性值. ...
- "getElementsByClassName is not a function" 报错原因
element.getElementsByClassName(""): 返回的含有该类的子元素数组,除了子元素以外的后代元素是获取不到的.要遍历使用,或者.element.getE ...
- 紫书 例题 9-5 UVa 12563 ( 01背包变形)
总的来说就是价值为1,时间因物品而变,同时注意要刚好取到的01背包 (1)时间方面.按照题意,每首歌的时间最多为t + w - 1,这里要注意. 同时记得最后要加入时间为678的一首歌曲 (2)这里因 ...
- 解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE(转)
问题 如下: 2017-07-16 08:50:57.436 INFO 13524 --- [ main] c.p.p.web.PointshopWebApplication ...
- 洛谷 P1732 [TJOI2011]序列
P1732 [TJOI2011]序列 题目描述 一指数列A={a1, a2, …, an},根据数列A计算数列B={b1, b2, …, bn},其中: 求\sum\limits^n_{i=1} b_ ...
- 使用python创建cocos2d-x项目
已准备条件: 已安装vs2012,已下载cocos2d-x sdk 2.2.3包. 旧版本号使用包里面的模板创建项目,如今新的包,使用python 来创建 1.下载安装 python https ...