Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simultaneously. There are two states for each skewer: initial and turned over.

This time Miroslav laid out nn skewers parallel to each other, and enumerated them with consecutive integers from 11 to nn in order from left to right. For better cooking, he puts them quite close to each other, so when he turns skewer number ii, it leads to turning kk closest skewers from each side of the skewer ii, that is, skewers number i−ki−k, i−k+1i−k+1, ..., i−1i−1, i+1i+1, ..., i+k−1i+k−1, i+ki+k (if they exist).

For example, let n=6n=6 and k=1k=1. When Miroslav turns skewer number 33, then skewers with numbers 22, 33, and 44 will come up turned over. If after that he turns skewer number 11, then skewers number 11, 33, and 44 will be turned over, while skewer number 22 will be in the initial position (because it is turned again).

As we said before, the art of cooking requires perfect timing, so Miroslav wants to turn over all nn skewers with the minimal possible number of actions. For example, for the above example n=6n=6 and k=1k=1, two turnings are sufficient: he can turn over skewers number 22 and 55.

Help Miroslav turn over all nn skewers.

Input

The first line contains two integers nn and kk (1≤n≤10001≤n≤1000, 0≤k≤10000≤k≤1000) — the number of skewers and the number of skewers from each side that are turned in one step.

Output

The first line should contain integer ll — the minimum number of actions needed by Miroslav to turn over all nn skewers. After than print ll integers from 11 to nn denoting the number of the skewer that is to be turned over at the corresponding step.

Examples
input

Copy
7 2
output

Copy
2
1 6
input

Copy
5 1
output

Copy
2
1 4
Note

In the first example the first operation turns over skewers 11, 22 and 33, the second operation turns over skewers 44, 55, 66 and 77.

In the second example it is also correct to turn over skewers 22 and 55, but turning skewers 22 and 44, or 11 and 55 are incorrect solutions because the skewer 33 is in the initial state after these operations.


借鉴一个大佬的,太强了。。。

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <xfunctional>
#define ll long long
#define mod 998244353
using namespace std;
int dir[][] = { {,},{,-},{-,},{,} };
const int maxn = ;
const long long inf = 0x7f7f7f7f7f7f7f7f; int main()
{
int n, k;
cin >> n >> k;
int mi = n % ( * k + );
if(mi>k)
mi = k + , printf("%d\n", n / ( * k + ) + );
else if (mi == )
mi = k + , printf("%d\n", n / ( * k + ));
else
{
printf("%d\n", n / ( * k + ) + );
}
for (; mi <= n; mi += * k + )
printf("%d ", mi);
return ;
}

Shashlik Cooking的更多相关文章

  1. CodeForces - 1040B Shashlik Cooking(水题)

    题目: B. Shashlik Cooking time limit per test 1 second memory limit per test 512 megabytes input stand ...

  2. A - Shashlik Cooking CodeForces - 1040B

    http://codeforces.com/problemset/problem/1040/B Long story short, shashlik is Miroslav's favorite fo ...

  3. CodeForces - 1040B Shashlik Cooking

    Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simu ...

  4. 【Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) B】Shashlik Cooking

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 翻转一次最多影响2k+1个地方. 如果n<=k+1 那么放在1的位置就ok.因为能覆盖1..k+1 如果n<=2k+1 ...

  5. 2018SDIBT_国庆个人第二场

    A.codeforces1038A You are given a string ss of length nn, which consists only of the first kk letter ...

  6. cooking构建工具报错MSBUILD :error MSB4132解决办法

    最近学习cooking构建工具的时候,在自己的笔记本上运行的好好的,项目在公司电脑上clone下来的时候,发现构建报错,逐条查错,试了好多方法也不行 最后在github上找到了答案,只是之前一直没找到 ...

  7. 2017浙江省赛 A - Cooking Competition ZOJ - 3958

    地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3958 题目: "Miss Kobayashi's Drag ...

  8. Cooking Schedule Problem Code: SCHEDULE(优先队列)

    Cooking Schedule Problem Code: SCHEDULE Chef is a well-known chef, and everyone wishes to taste his ...

  9. 【Shashlik.EventBus】.NET 事件总线,分布式事务最终一致性

    [Shashlik.EventBus].NET 事件总线,分布式事务最终一致性 简介 github https://github.com/dotnet-shashlik/shashlik.eventb ...

随机推荐

  1. 为实践javaweb项目,搭建了相应环境

    为实践javaweb项目,搭建了相应环境,现总结一下. JDK与JRE的安装与配置 前提准备: 1.我们下载的JDK安装包里面既包含JDK又包含JRE: 2.要确认你的电脑里面没有JDK和JRE的残留 ...

  2. javaSE学习笔记(15) ---缓冲流、转换流、序列化流

    javaSE学习笔记(15) ---缓冲流.转换流.序列化流 缓冲流 昨天复习了基本的一些流,作为IO流的入门,今天我们要见识一些更强大的流.比如能够高效读写的缓冲流,能够转换编码的转换流,能够持久化 ...

  3. ORACLE10G非归档模式下RMAN异机迁库

    环境信息: 源库 目标库 操作系统 WIN7 WIN SVR 2012 R2 IP x.x.x.216 x.x.x.112 数据库版本 10.2.0.4.0 - 64bi 10.2.0.4.0 - 6 ...

  4. C#简单的LogHelper

    适用于不想使用log4net等第三方的Log工具的LogHelper.正规的还是要使用<C# 工具类LogHelper>的这种做法. using System; using System. ...

  5. 一维数组、二维数组——Java

    一. 一维数组 1.  数组是相同类型数据的有序集合 相同类型的若干个数据,按照一定先后次序排列组合而成 每个数组元素可以通过一个下标来访问它们 其中,每一个数据称作一个数组元素 2. 数组特点: 其 ...

  6. ios输入法弹出输入框定位错乱

    弹出输入框会使视口高度发生变化,弹出输入框后动态匹配这个高度 以下是使用jq的方法 $('input').on('blur', function () { setTimeout(function () ...

  7. 初识linux&常用命令&目录文件的浏览和管理

    Linux系统的主要用途:主要用于服器务器,特别是网络服务 Linux命令格式 命令   [选项]  [ 参数] 命令:告诉操作系统做什么,执行什么 选项:说明命令的运行方式(可以改变命令的功能).选 ...

  8. ubuntu16.04更换成国内源

    一.首先使用自带的vi编辑器 安装完ubuntu后没有默认的root密码,如果要设置root密码需要进行如下步骤: 1 sudo passwd 2 连续输入两次新密码 二.vi编辑器下使用[backs ...

  9. 堆之*bin理解

    在程序运行中,使用bins结构对释放的堆块进行管理,以减少向系统申请内存的开销,提高效率. chunk数据结构 从内存申请的所有堆块,都使用相同的数据结构——malloc_chunk,但在inuse和 ...

  10. BZOJ 3280: 小R的烦恼

    Description 小R最近遇上了大麻烦,他的程序设计挂科了.于是他只好找程设老师求情.善良的程设老师答应不挂他,但是要 求小R帮助他一起解决一个难题.问题是这样的,程设老师最近要进行一项邪恶的实 ...