【Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) B】Shashlik Cooking
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
翻转一次最多影响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的更多相关文章
- 【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的. ...
- 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 ...
- 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不可约分,如果存在多组满足 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 【Codeforces Round #430 (Div. 2) A C D三个题】
·不论难度,A,C,D自己都有收获! [A. Kirill And The Game] ·全是英文题,述大意: 给出两组区间端点:l,r,x,y和一个k.(都是正整数,保证区间不为空),询问是否 ...
随机推荐
- solaris x86安装ORACLE 11.2.0.3软件时因SWAP不足报错: INFO: ld: fatal: mmap anon failed
1.ORACLE软件安装到86%时报错,图忘截了.日志例如以下: /oracle/u01/app/oracle/product/11.2.0/ INFO: db_1/lib/sysliblist` - ...
- <LeetCode OJ> 31. Next Permutation
31. Next Permutation Total Accepted: 54346 Total Submissions: 212155 Difficulty: Medium Implement ne ...
- 图像处理中的数学原理具体解释20——主成分变换(PCA)
欢迎关注我的博客专栏"图像处理中的数学原理具体解释" 全文文件夹请见 图像处理中的数学原理具体解释(总纲) http://blog.csdn.net/baimafujinji/ar ...
- wpf datagridtemplatecolumn visibility binding
因为datagridtemplatecolumn不在Virsual Tree中,不能继承DataGrid的DataContext, 所以想要绑定到datagridtemplatecolumn的 vis ...
- libcanbus官方主页
libcanbus canbus(CAN BUS V2.0 B)扩展格式库项目简析 注: 本文如果你已经有linux开发环境 请确保你使用本库时是tag版本号. 该库遵循的协议是SAE J1939-2 ...
- 【转】寻找最好的笔记软件:海选篇 (v1.0)
原文网址:http://blog.sina.com.cn/s/blog_46dac66f01000b55.html 序言: 我见过的多数软件爱好者,无论是资深用户,还是初级用户,都有一个梦想:找到 ...
- JavaScript 面向对象(随笔)
构造函数创建对象 1构造函数是用new创建对象时调用的函数,与普通唯一的区别是构造函数名应该首字母大写. function Person() { this.age = 50; } let a = ne ...
- ACM_支离破碎(递推dp)
支离破碎 Time Limit: 4000/2000ms (Java/Others) Problem Description: 远古时期有一位魔王想向一座宫殿里的公主求婚.为了考验魔王的智力,太后给了 ...
- Bootstrap 模态框使用
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- Fiddler-AutoResponder 修改接口数据
问题 App 功能测试时,有些场景需要特殊的数据,如 App 对极限值的处理:或是账单列表的时间需要显示刚刚.昨天.周几,需要接口返回不同的时间.更改数据库是一种方法,但不够灵活,一些复杂的场景也不好 ...