A - Shashlik Cooking CodeForces - 1040B
http://codeforces.com/problemset/problem/1040/B
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 22will 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 nndenoting the number of the skewer that is to be turned over at the corresponding step.
Examples
7 2
2
1 6
5 1
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 operatio
#include<stdio.h> int n,k,sum,num;
int a[+]; int main()
{
while(~scanf("%d%d",&n,&k))
{
num=*k+;
if(n%(*k+)==)
{
num=n/num;
}
else
{
num=n/num+;
}
printf("%d\n",num);
int b=,a;
for(int i=;i<=k+;i++)
{
if(n-i-(num-)*(*k+)<=k)
{
b=i;
break;
}
} printf("%d",b);
for(int i=;i<=num;i++)
{
b+=*k+;
printf(" %d",b);
}
printf("\n");
}
return ;
}
A - Shashlik Cooking CodeForces - 1040B的更多相关文章
- CodeForces - 1040B Shashlik Cooking(水题)
题目: B. Shashlik Cooking time limit per test 1 second memory limit per test 512 megabytes input stand ...
- CodeForces - 1040B Shashlik Cooking
Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simu ...
- 【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 ...
- Shashlik Cooking
Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simu ...
- 2018SDIBT_国庆个人第二场
A.codeforces1038A You are given a string ss of length nn, which consists only of the first kk letter ...
- Codeforces Round #326 (Div. 2) A. Duff and Meat 水题
A. Duff and Meat Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/588/probl ...
- Codeforces Gym 100342D Problem D. Dinner Problem Dp+高精度
Problem D. Dinner ProblemTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1003 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
随机推荐
- EF Migrations error: No connection string named 'MpDb' could be found in the application config file.
solution: update-database 命令查找连接字符是在当前启动项目中找的 确保启动项目中connectiongString配置存在.
- IDC机房机器日志采集配置
以机器 gpu-server-011 为例: 机房机器添加AliUids操作 [root@gpu-server-011 ~]# mkdir -p /etc/ilogtail/users/ [root ...
- Docker入门 - 005 Docker 容器连接
Docker 容器连接 前面我们实现了通过网络端口来访问运行在docker容器内的服务.下面我们来实现通过端口连接到一个docker容器 网络端口映射 我们创建了一个 python 应用的容器. do ...
- 【PHP】解析PHP的GD库
官方文档:http://php.net/manual/en/book.image.php 1.GD库简介 PHP可以创建和操作多种不同格式的图像文件.PHP提供了一些内置的图像信息函数,也可以使用GD ...
- 【PHP】解析PHP中的数组
目录结构: contents structure [-] 创建数组 删除数组 栈结构 常用的数组处理函数 在这篇文章中,笔者将会介绍PHP中数组的使用,以及一些注意事项.之前笔者已经说过PHP是一门弱 ...
- python 验证码识别示例(一) 某个网站验证码识别
某个招聘网站的验证码识别,过程如下 一: 原始验证码: 二: 首先对验证码进行分析,该验证码的数字颜色有变化,这个就是识别这个验证码遇到的比较难的问题,解决方法是使用PIL 中的 getpixel ...
- MUI框架的缩写输入
html 上面--代表最小触发字符 下面--代表非必要完整触发字符 组件 触发字符 mDoctype(mui-dom结构) mdo ctype mBody(主体) mbo dy m ...
- P图软件瘦脸眼睛放大和手动瘦身功能
一直以为是OpenCV写的没想到OpenGL能够做的东西比我想象的多. https://blog.csdn.net/zfgrinm/article/details/79291693 https://b ...
- Java编程的逻辑 (88) - 正则表达式 (上)
本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http:/ ...
- hdoj:2081
手机短号 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...