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. egg 提交数据 防csrf 攻击 配置

    await ctx.render('from',{csrf:this.ctx.csrf}); 或者 使用中间件 ctx.state.csrf = ctx.csrf;

  2. wordpress<=4.6版本任意命令执行漏洞

    漏洞简述 当WordPress 使用 PHPMailer 组件向用户发送邮件.攻击者在找回密码时会使用PHPmailer发送重置密码的邮件,利用substr(字符串截取函数).$run(系统调用函数) ...

  3. 四种常用的通知类型(xml)

    1.maven依赖 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="h ...

  4. .NET MVC强类型参数排除和包含

    MVC接收强类型对象时排除或只接收某几个属性使用Bind特性 只接收几个属性:Bind(Include="属性1,属性2,属性3,...") 排除某几个属性:Bind(Exclud ...

  5. 【笔记】机器学习 - 李宏毅 - 6 - Logistic Regression

    Logistic Regression 逻辑回归 逻辑回归与线性回归有很多相似的地方.后面会做对比,先将逻辑回归函数可视化一下. 与其所对应的损失函数如下,并将求max转换为min,并转换为求指数形式 ...

  6. Magento2 updated quote_item table - 更新quote_item 表自定义字段

    /** * @param $class * @return mixed */ public function mc_get_obj($class) { return \Magento\Framewor ...

  7. Uva12169 扩展欧几里得模板

    Uva12169(扩展欧几里得) 题意: 已知 $x_i=(a*x_{i-1}+b) mod 10001$,且告诉你 $x_1,x_3.........x_{2t-1}$, 让你求出其偶数列 解法: ...

  8. 嵊州D5T2 折纸 folding

    折纸 folding [问题描述] 在非常紧张的 NOIP 考试中,有人喜欢啃指甲,有人喜欢转铅笔,有人喜欢撕 纸条,……而小 x 喜欢迷折纸. 现有一个 W * H 的矩形纸张,监考老师想知道,小 ...

  9. [CTSC2008]网络管理 [树剖+整体二分]

    这题的复杂度可以到达惊人的\(\log^4\)据说还能跑过去(差点没吓死我 直接二分+树剖树套树(\(n \log^4 n\)) 一个\(\log\)也不少的4\(\log\) 但是我有个\(\log ...

  10. gulp常用插件之gulp-inject使用

    更多gulp常用插件使用请访问:gulp常用插件汇总 gulp-inject这个插件的作用与wiredep类似,不同的是可以自己任意指定需要插入文件的列表.它同样是利用注释来寻找插入的位置.获取源文件 ...