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

【题意】

在这里输入题意

【题解】

翻转一次最多影响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. ScrollViewer滚动究竟来触发载入数据的Behavior

    近期项目中遇到载入数据的性能问题, 原因是.net4.0的虚拟化支持不够完毕,有好多bug在4.5才修复. 我们仅仅能利用大家通用的做法来延迟载入数据: 每次载入固定少量的数据.当拖动究竟后.继续载入 ...

  2. python实现高速排序算法(两种不同实现方式)

    # -*- coding: utf-8 -*- """ Created on Fri May 16 17:24:05 2014 @author: lifeix " ...

  3. crm高速开发之OrganizationService

    这是主要的开发模式: /* 创建者:菜刀居士的博客  * 创建日期:2014年07月06号  */ namespace Net.CRM.OrganizationService {     using ...

  4. jsp页面自动换行

    其实只要在表格控制中添加一句 <div style="word-break:break-all">就搞定了.</div>其中可能对英文换行可能会分开一个单词 ...

  5. 【联系】二项分布的对数似然函数与交叉熵(cross entropy)损失函数

    1. 二项分布 二项分布也叫 0-1 分布,如随机变量 x 服从二项分布,关于参数 μ(0≤μ≤1),其值取 1 和取 0 的概率如下: {p(x=1|μ)=μp(x=0|μ)=1−μ 则在 x 上的 ...

  6. 26. Remove Duplicates from Sorted Array[E]删除排序数组中的重复项

    题目 Given a sorted array nums, remove the duplicates in-place such that each element appear only once ...

  7. Hashmap 详解和迭代器问题

    重点介绍HashMap.首先介绍一下什么是Map.在数组中我们是通过数组下标来对其内容索引的,而在Map中我们通过对象来对对象进行索引,用来索引的对象叫做key,其对应的对象叫做value.在下文中会 ...

  8. NPOI导出功能

    利用NPOI组件将数据中想要的数据导出到excel表格中. demo如下 using System; using System.Collections.Generic; using System.Li ...

  9. 第二次作业&熟悉使用工具

     GIT地址  我的地址  GIT用户名  995020892w  学号后五位  81105  博客地址  我的博客  作业链接  第二次作业 一.环境配置过程 安装vs2017 因为以前学习C#相关 ...

  10. css round corner div and transition

    看stackoverflow上的圆角标签挺好看,自己动手试了下,用的属性是border-radius(即边框圆角半径,用px):加上transition effect,代码如下: <!DOCTY ...