题解——Codeforces Round #507 (based on Olympiad of Metropolises) T2(模拟)
T2还是模拟
枚举一下第一个放哪里
然后贪心的反转即可
虽然我也不会证,但是这题肯定有解qwq
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n,k,ans=0x3f3f3f3f,path[],midpath[],midans;
int main(){
scanf("%d %d",&n,&k);
for(int i=;i<=k+;i++){
int l=i,r=k+i;
midans=;
midpath[]=i;
while(r<n){
midans++;
l=r+;
r=l+*k;
// printf("%d %d\n",l,r);
midpath[midans]=k+l;
}
if(midans<ans){
ans=midans;
memcpy(path,midpath,sizeof(midpath) );
}
}
printf("%d\n",ans);
for(int i=;i<=ans;i++)
printf("%d ",path[i]);
return ;
}
题解——Codeforces Round #507 (based on Olympiad of Metropolises) T2(模拟)的更多相关文章
- 题解——Codeforces Round #507 (based on Olympiad of Metropolises) T1 (模拟)
暴力模拟即可 就是情况略多 #include <cstdio> #include <algorithm> #include <cstring> using name ...
- Codeforces Round #583 (Div. 1 + Div. 2, based on Olympiad of Metropolises) A题
A. Optimal Currency ExchangeAndrew was very excited to participate in Olympiad of Metropolises. Days ...
- [题解] Codeforces Round #549 (Div. 2) B. Nirvana
Codeforces Round #549 (Div. 2) B. Nirvana [题目描述] B. Nirvana time limit per test1 second memory limit ...
- Codeforces Round #367 (Div. 2) B. Interesting drink (模拟)
Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to res ...
- 【Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) B】Shashlik Cooking
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 翻转一次最多影响2k+1个地方. 如果n<=k+1 那么放在1的位置就ok.因为能覆盖1..k+1 如果n<=2k+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的. ...
- 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) 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)
A. Fraction 题目链接:http://codeforces.com/contest/854/problem/A 题目意思:给出一个数n,求两个数a+b=n,且a/b不可约分,如果存在多组满足 ...
随机推荐
- url中是否加斜杠/
通常来说,不加斜杠的形式(如”example.jsp”)请求的是相对于当前页面路径的资源 http://localhost:8080/webapp/examole:加斜杠的形式(”/example.j ...
- Game (思维)
#include<bits/stdc++.h> using namespace std; ; char str[maxn][maxn]; int cntx[maxn], cnty[maxn ...
- xpath ,css
https://docs.scrapy.org/en/latest/intro/tutorial.html xpath @选择属性 .当前目录下选择 //任意路径选择 /bookstore/book ...
- noip200605能量项链
题解: 状态转移方程为:dp[i][j] = max{dp[i][k] + dp[k+1][j] + a[i]*a[k+1]*a[j+1]}, k=i, ..., j-1, i和j都从1开始.dp[i ...
- python内置函数bin
bin() 返回一个整数 int 或者长整数 long int 的二进制表示. 代码示例: print(bin(10)) 运行结果: F:\dev\python\python.exe F:/pyCha ...
- formdata 和 Payload 区别
FormData和Payload是浏览器传输给接口的两种格式,这两种方式浏览器是通过Content-Type来进行区分的(了解Content-Type),如果是 application/x-www-f ...
- Google自动广告,将广告代码放置在 HTML 中的什么位置?
Google自动广告,将广告代码放置在 HTML 中的什么位置? 为自动广告生成广告代码后,您需要将此代码放置在要展示广告的每个网页中.您应将广告代码放置在网页的 <head> 标记(或正 ...
- UART接口与COM口的区别
原文地址:https://blog.csdn.net/wordwarwordwar/article/details/78883732 简单的讲:(UART与COM) 嵌入式里面说的串口,一般是指UAR ...
- AtCoder Beginner Contest 044 C - 高橋君とカード / Tak and Cards
题目链接:http://abc044.contest.atcoder.jp/tasks/arc060_a Time limit : 2sec / Memory limit : 256MB Score ...
- kubernetes install for centos
官方的文档写的很清楚 https://kubernetes.io/docs/getting-started-guides/centos/centos_manual_config/ 如果已经安装过doc ...