题目链接:http://codeforces.com/contest/1040/problem/B

B. Shashlik Cooking

time limit per test

1 second

memory limit per test

512 megabytes

input

standard input

output

standard output

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 llintegers 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>
using namespace std;
int main()
{int n,k,d,i,q,r;cin>>n>>k;d=2*k+1;q=n/d;r=n%d;if(r!=0)q++;elser=2*k;cout<<q<<endl;for(i=1+r/2;i<=n;i+=d)cout<<i<<" ";return 0;
}

B. Shashlik Cooking相关推荐

  1. 1040B. Shashlik Cooking

    B. Shashlik Cooking:题目 思路,如果所有烤肉都可以一次就行,如果不行就去前面调整一下 #include <bits/stdc++.h> using namespace ...

  2. 【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 ...

  3. option样式美化 css,CSS select样式优化

    下拉选择菜单基本的CSS样式不怎么好看,通过一些简单的样式优化,就可以起到美化的作用了. 请选择您所在的城市 请选择您所在的城市 中山市 太原市 广州市 CSS样式 .sel_wrap{ height ...

  4. 用 cooking 搭建一个简单又优雅的 Vue 项目开发环境 (入门篇)

    本文适合 Vue 的初学者,以及对 webpack 不熟悉的同学阅读.前提是你要会用基本的命令行. Node 和 NPM,以及掌握 ES2015 的基础知识.本文都是在 macOS 环境下运行,要求使 ...

  5. Java跨域请求cooking共享,关于HTML5中的sessionStorage和localStorage

    需求: 做项目的时大多数情况下我们需要对请求的数据进行多次复用,为了降低请求次数我们需要对请求的数据进行本地存储: 以前用的cooking来存储为本地数据,HTML5后提出sessioStorage. ...

  6. UE4 Packaging and Cooking Games

    Packaging & Cooking Packaging Projects Launching to Devices Content Cooking Releasing Your Proje ...

  7. RFID Cooking with Mifare Classic

    转自: http://www.backtrack-linux.org/wiki/index.php/RFID_Cooking_with_Mifare_Classic Contents [hide] 1 ...

  8. [生而为人-思考] Knowledge Cooking -5th 分享会记录

    Knowledge Cooking 这是我发起的一个校内愉快小团体 第五次分享 时间:2017.11.25夜 地点:HQU 分享人:阿江 参与人数:18 回顾与热场 中国传统教育中缺失的三种教育:性. ...

  9. php 网页爬虫 cooking,scrapy爬取dmoz/Home

    一.实验背景 此次实验要求我们爬取DMOZ下的Home目录(http://www.dmoztools.net/Home/)的所有子目录.dmoz/Home子目录如图001所示. image001.pn ...

  10. [生而为人-思考] Knowledge Cooking 分享会记录 -1

    "Knowledge Cooking" 这是我在学校发起的一个愉快的小团体 定性有N种: 认知分享会 技能分享会 段子大会 吹牛大会 读书会 人才校友交流会 无上限无下限的思考会 ...

最新文章

  1. Android :landscape||portrait 切换
  2. tomcat启动命令行窗口出现乱码的解决方法
  3. qt icon如何显示gif_收集Qt支持的emoji表情-第五弹
  4. ELK错误1_Kafka-Logstash-Elasticsearch过程,Elasticsearch报grokparsefailure错误
  5. 【Thymeleaf】格式化数字
  6. java mapreduce 实例_MapReduce -- JAVA 实例(一)计算总数
  7. 领域驱动设计(DDD)的精髓
  8. 计算机应用乘法,计算机系统原理(十) 二进制整数的乘法运算和除法运算
  9. 10一个应用阻止关机贴吧_手机该不该每天关机一次?看完才知道这么多年白用了...
  10. oracle 存储同步,Oracle数据库知识——存储过程篇
  11. stm32 hal 串口只可以接收到一包数据数据
  12. Ubuntu系统下ntp服务器搭建2
  13. JAR包中读取资源文件
  14. 如何解决软键盘弹出引起的各种不适
  15. 美网络司令部:马上修复严重的 PAN-OS 漏洞,免遭国家黑客攻击
  16. JS复制文本到剪切板
  17. Delphi微信公众号开发
  18. python的基础列表_python基础入门 列表
  19. 【Android P】 JobScheduler服务源码解析(二) ——框架解析
  20. 让老照片重现光彩(三):完整论文的中文译文

热门文章

  1. matlab怎么增加图例,将图例添加到图 - MATLAB Simulink - MathWorks 中国
  2. 软件架构之前后端分离与前端模块化发展史
  3. Swarm-BZZ踩坑日记之 如何在Linux下使用docker开30个bzz节点
  4. 电脑怎么显示文件后缀名?3个步骤
  5. Java学习笔记 | Java异常处理
  6. SSM Service ServiceImpl 优缺点
  7. 2021免费注册TK域名使用一年的方法
  8. 网页压缩 - GZIP
  9. 回溯法 子集和问题
  10. allegro元器件对齐