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

【题意】

在这里输入题意

【题解】

翻转一次最多影响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. Linux GDB程序调试工具使用简单介绍

    GDB概述 GDB是GNU开源组织公布的一个强大的UNIX下的程序调试工具.也许,各位比較喜欢那种图形界面方式的,像VC.BCB等IDE的调试,但假设你是在UNIX平台下做软件,你会发现GDB这个调试 ...

  2. asp.net控件的异步刷新

    需求:我们知道,asp.net控件中的button控件,默认是开启了自己主动回发的,而有时候.我们不想刷新整个界面.而仅仅想局部刷新,可页面中又偏偏用到了.net button控件. 尽管我非常讨厌. ...

  3. oc7--内存分析

    // // main.m // 第二个OC类 #import <Foundation/Foundation.h> @interface Person : NSObject { @publi ...

  4. Unsupported major.minor version 52.0 (unable to load class XXX

    java项目构建从高版本JDK改为低版本JDK报错.这是再次编译时使用的JDK版本比你原来编译的版本低所导致的. 转自:http://blog.csdn.net/zixiao217 maven项目在服 ...

  5. x+=y与x=x+y相同吗?

    为了将赋值操作简便化,Java提供了很多扩展赋值运算符,例如+=.-=./=.*=等等,那么问题来了,x += 1与x = x +1两者相同吗? public class EqualsTest { @ ...

  6. POJ 3122 二分

    大致题意: 就是公平地分披萨pie 我生日,买了n个pie,找来f个朋友,那么总人数共f+1人 每个pie都是高为1的圆柱体,输入这n个pie的每一个尺寸(半径),如果要公平地把pie分给每一个人(就 ...

  7. Splash Screen(短时间弹出框,信息显示一次)

    原文引自codeproject site, http://www.codeproject.com/Articles/6511/Transparent-Splash-Screen 1.A splash ...

  8. 最简单的一致性Hash算法实现

    import java.util.Collection;import java.util.SortedMap;import java.util.TreeMap; public class Consis ...

  9. VHDL_LIB之DFF

    1 D-Flip-Flop with async reset or set library IEEE; use ieee.std_logic_1164.all; entity FFD is gener ...

  10. CUDA5.5入门文章:VS10设置

    原文链接:http://blog.csdn.net/augusdi/article/details/12205435 作者专栏:http://blog.csdn.net/augusdi/article ...