题解——Codeforces Round #507 (based on Olympiad of Metropolises) T2(模拟)

Posted dreagonm

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了题解——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[1200],midpath[1200],midans;
int main(){
  scanf("%d %d",&n,&k);
  for(int i=1;i<=k+1;i++){
  int l=i,r=k+i;
  midans=1;
  midpath[1]=i;
  while(r<n){
    midans++;
    l=r+1;
    r=l+2*k;
  //  printf("%d %d
",l,r);
    midpath[midans]=k+l;
    }
  if(midans<ans){
    ans=midans;
    memcpy(path,midpath,sizeof(midpath) );
    }
  }
  printf("%d
",ans);
  for(int i=1;i<=ans;i++)
    printf("%d ",path[i]);
  return 0;
}

 

以上是关于题解——Codeforces Round #507 (based on Olympiad of Metropolises) T2(模拟)的主要内容,如果未能解决你的问题,请参考以下文章

Educational Codeforces Round 61 (Rated for Div. 2)F(区间DP,思维,枚举)

Educational Codeforces Round 83 (Rated for Div. 2)E(区间DP)

Codeforces Round #815 (Div. 2) 题解

Codeforces Round #805 (Div. 3) 题解

Codeforces Educational Codeforces Round 54 题解

Codeforces Round #637 (Div. 2) 题解