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−k, i−k+1, ..., i−1, i+1, ...,i+k−1, i+k (if they exist).
For example, let n=6 and k=1. When Miroslav turns skewer number 3, then skewers with numbers 2, 3, and 4 will come up turned over. If after that he turns skewer number 1, then skewers number 1, 3, and 4 will be turned over, while skewer number 2 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 nnskewers with the minimal possible number of actions. For example, for the above example n=6 and k=1, two turnings are sufficient: he can turn over skewers number 2 and 5.
Help Miroslav turn over all nn skewers.
Input
The first line contains two integers nn and kk (1≤n≤1000, 0≤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 1 to nn denoting the number of the skewer that is to be turned over at the corresponding step.
Examples
Input
7 2
Output
2
1 6
Input
5 1
Output
2
1 4
Note
In the first example the first operation turns over skewers 1, 2 and 3, the second operation turns over skewers 4, 5, 6 and 7.
In the second example it is also correct to turn over skewers 2 and 5, but turning skewers 2 and 4, or 1and 5 are incorrect solutions because the skewer 3 is in the initial state after these operations.
题解:当k=0时,需要翻n次;当n≤2×k+1时,只需要中间的翻一次;当n>2×k+1时,要具体确定关系,判断从哪里开始翻。
代码如下:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define swap(a,b) (a=a+b,b=a-b,a=a-b)
#define maxn 320007
#define N 100000000
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e 2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define read(x) scanf("%d",&x)
#define put(x) printf("%d\n",x)
#define memset(x,y) memset(x,y,sizeof(x))
#define Debug(x) cout<<x<<" "<<endl
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
//std::ios::sync_with_stdio(false);
//cin.tie(NULL);
using namespace std;
int a[111111],b[111111];
int main()
{
int n,k,ans;
cin>>n>>k;
int s=2*k+1;
if(!k)
{
ans=n;
for(int i=0; i<n; i++)
a[i]=i+1;
}
else if(n<=s)
{
ans=1;
a[0]=n/2+1;
}
else if(n>s)
if(n%s>k||!(n%s))
{
ans=0;
for(int i=k;i<n;i+=s)
a[ans++]=i+1;
}
else
{
ans=0;
for(int i=0;i<n;i+=s)
a[ans++]=i+1;
}
cout<<ans<<endl<<a[0];
for(int i=1;i<ans;i++)
cout<<" "<<a[i];
return 0;
}