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 ...
随机推荐
- Python并行实例
任务 def single(): # 单进程单线程实现 s = 0 for i in range(1, N): s += math.sqrt(i) return s 结论 Python多线程无法利用多 ...
- Web API中如何获取相对地址的绝对地址 Server.MapPath
var sPath = System.Web.Hosting.HostingEnvironment.MapPath("/FilePath/");
- “The subscription does not exist” when a distributor primary replica fails over to a replica that does not use the same agent profile
Symptoms Consider the following scenario: In Microsoft SQL Server 2017, you have a distribution agen ...
- Thymeleaf模版--子页面单独引入CSS、JS文件
https://blog.csdn.net/u010392801/article/details/80465800 ****************************************** ...
- Android Studio项目导入aar包报错
最近在试着接入TrPay的sdk,根据它家文档需要导入它们的aar包(paysdk-release-1.2.2.aar). 在AS中怎么给安卓项目导入aar包,网上搜一下就能看到无非也就下面三步: 1 ...
- hdoj:2048
#include <iostream> using namespace std; ]; ]; int main() { int C; a[] = ; a[] = ; b[] = ; b[] ...
- [转]application.properties详解 --springBoot配置文件
本文转载:http://blog.csdn.net/lpfsuperman/article/details/78287265###; # spring boot application.propert ...
- http 请求 post get 长度限制
一.问题起因在某项目释放后Bug统计的附件<释放后问题>里有: 问题 原因 分析 备注 CSV处理时,如果处理的主题数过多,发生URL参数上限的错误: 可变长度的参数通过UR ...
- SpirngBoot之整合Swagger2
前言 swagger,中文"拽"的意思.它是一个功能强大的api框架,它的集成非常简单,不仅提供了在线文档的查阅, 而且还提供了在线文档的测试.另外swagger很容易构建rest ...
- GraphX学习笔记——Programming Guide
学习的资料是官网的Programming Guide https://spark.apache.org/docs/latest/graphx-programming-guide.html 首先是Gra ...