【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

翻转一次最多影响2*k+1个地方。
如果n

【代码】

#include <bits/stdc++.h>
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define lson l,mid,rt<<1
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x)
#define rson mid+1,r,rt<<1|1
using namespace std; const double pi = acos(-1);
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0}; const int N = 20; int n,k; int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
scanf("%d%d",&n,&k);
if (k+1>=n){
cout<<1<<endl;
cout<<1<<endl;
return 0;
}else if (2*k+1>=n){
//n>k+1
cout<<1<<endl;
cout<<k+1<<endl;
return 0;
}
int temp = n%(2*k+1);
int points = n/(2*k+1);
if (temp==0){
printf("%d\n",points);
int x = k+1;
rep1(i,1,points){
cout<<x<<' ';
x = x+k+1+k;
}
}else {
if (temp>=k+1){
points++;
cout<<points<<endl;
int x = temp-k;
rep1(i,1,points){
cout<<x<<' ';
x = x + k+1+k;
}
}else{
//temp<=k
points++;
cout<<points<<endl;
cout<<1<<' ';
points--; int x = 1;
rep1(i,1,points){
x = x+k+1+k;
cout<<x<<' ';
}
}
}
return 0;
}

【Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) B】Shashlik Cooking的更多相关文章

  1. 【Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) A】Palindrome Dance

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] i从1..n/2循环一波. 保证a[i]和a[n-i+1]就好. 如果都是2的话填上min(a,b)*2就好 其他情况跟随非2的. ...

  2. Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) D mt19937

    https://codeforces.com/contest/1040/problem/D 用法 mt19937 g(种子); //种子:time(0) mt19937_64 g(); //long ...

  3. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises)

    A. Fraction 题目链接:http://codeforces.com/contest/854/problem/A 题目意思:给出一个数n,求两个数a+b=n,且a/b不可约分,如果存在多组满足 ...

  4. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) D. Jury Meeting(双指针模拟)

    D. Jury Meeting time limit per test 1 second memory limit per test 512 megabytes input standard inpu ...

  5. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) D

    Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the ...

  6. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) C

    Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n ...

  7. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) B

    Maxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has n apartme ...

  8. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) A

    Petya is a big fan of mathematics, especially its part related to fractions. Recently he learned tha ...

  9. 【Codeforces Round #430 (Div. 2) A C D三个题】

    ·不论难度,A,C,D自己都有收获! [A. Kirill And The Game] ·全是英文题,述大意:    给出两组区间端点:l,r,x,y和一个k.(都是正整数,保证区间不为空),询问是否 ...

随机推荐

  1. Jemeter第一个实例

    http://www.jianshu.com/p/0e4daecc8122?from=timeline&isappinstalled=0 学习地址:http://leafwf.blog.51c ...

  2. maven环境配置好,一直提示mvn不是内部命令

    设置了环境变量  M2_HOME  跟path  ,在cmd中输入mvn一直提示不是内部命令 解决办法:通过命令设置path 如下:set  path=输入值

  3. [iOS]UITableViewController完毕收回键盘操作

    UITableViewController 本身可以实现键盘适配(cell中控件焦点会移动到键盘上方 在做键盘收回的时候思考过例如以下方案 1.tableview加入点击事件 结果:点击事件和tabl ...

  4. luogu1403 约数研究

    题目大意:给出n,求1~n所有数的约数个数的和. 将“1~n所有数的约数”的模板中的factor[i*j].push_back(i)改为FactorCnt[i*j]++,最后再求一次和即可. #inc ...

  5. POJ3087 Shuffle'm Up

    题目: 现有字符串s1.s2.s12,其中s1.s2的长度为len,s12的长度为2*len. 是否可以通过一些操作使s1和s2转换合并成s12? 变换的操作规则如下: 假设s1=11111,s2=0 ...

  6. linux Redis 5.0集群搭建

    文档结构如下: Redis cluster 是redis的分布式解决方案,在3.0版本正式推出后,有效的解决了redis分布式方面的需求:当遇到单机内存,并发,流量等瓶颈是,可以采用cluster架构 ...

  7. JavaScript 面向对象(随笔)

    构造函数创建对象 1构造函数是用new创建对象时调用的函数,与普通唯一的区别是构造函数名应该首字母大写. function Person() { this.age = 50; } let a = ne ...

  8. POJ 2492 A Bug's Life 带权并查集

    题意: 思路: mod2 意义下的带权并查集 如果两只虫子是异性恋,它们的距离应该是1. 如果两只虫子相恋且距离为零,则它们是同性恋. (出题人好猥琐啊) 注意: 不能输入一半就break出来.... ...

  9. Selenium等待某个元素出现之隐式等待

    找不到元素这个问题困扰了两天了,一直怀疑是页面div层次太多,定位不准确.于是就从table开始到最后一层精确定位,仍然找不元素.怎么办,在网上搜索答案,说是可以加个隐式试试,于是在执行前加了一句等待 ...

  10. Unity3d Time

    using UnityEngine; using System.Collections; public class test1 : MonoBehaviour { public float angle ...