首先我们先观察三个串 1010,110110,11101110,答案都是红色部分,我们可以下一个结论,形如 abab ( a 中有非负整数个 1 , b 中只有一个 0 )这类的字符串答案恒为 2 ,也就是 k==2 ,然后就是用这类字符串去构造出我们所需的 k 。我们可以尝试从末尾加一个1,那么之前的串变成了 10101,1101101,111011101,那么答案为红色部分。我们可以发现,通过我们末尾添加的1,导致之前红色部分的 与我们末尾添加的1与前面一个0构成的 重复,使得之前的红色部分向后挪一位。于是,我们可以用这一规律去构造出我们想要的k,显然答案就是末尾部分的01(蓝色部分111...10111...10111)满足 0 的个数加 1 的个数等于 k-1  ,那么对中间的影响(绿色部分111...1011111...110111)往后挪一位也就是我们的答案 k ,最后就是算出这形如 abab 字符串 a 部分中的 1 的个数有多少就行了,设 x 为 a 中 1 的个数,方程为 2*x+1+k-1=n  ,化简为 x=(n-k)/2 ,根据题意 n 与 k 同奇偶,那么 x 也是唯一确定的,最后构造也由此生成。

 //      ——By DD_BOND

 //#include<bits/stdc++.h>
#include<functional>
#include<algorithm>
#include<iostream>
#include<sstream>
#include<iomanip>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<cstddef>
#include<cstdio>
#include<memory>
#include<vector>
#include<cctype>
#include<string>
#include<cmath>
#include<queue>
#include<deque>
#include<ctime>
#include<stack>
#include<map>
#include<set> #define fi first
#define se second
#define MP make_pair
#define pb push_back
#define INF 0x3f3f3f3f
#define pi 3.1415926535898
#define lowbit(a) (a&(-a))
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define Min(a,b,c) min(a,min(b,c))
#define Max(a,b,c) max(a,max(b,c))
#define debug(x) cerr<<#x<<"="<<x<<"\n"; using namespace std; typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef unsigned long long ull; const ll LLMAX=2e18;
const int MOD=1e9+;
const double eps=1e-;
const int MAXN=1e6+;
const int hmod1=0x48E2DCE7;
const int hmod2=0x60000005; inline ll sqr(ll x){ return x*x; }
inline int sqr(int x){ return x*x; }
inline double sqr(double x){ return x*x; }
ll __gcd(ll a,ll b){ return b==? a: __gcd(b,a%b); }
ll qpow(ll a,ll n){ll sum=;while(n){if(n&)sum=sum*a%MOD;a=a*a%MOD;n>>=;}return sum;}
inline int dcmp(double x){ if(fabs(x)<eps) return ; return (x>? : -); } int main(void)
{
ios::sync_with_stdio(false); cin.tie(); cout.tie();
int n,k; cin>>n>>k;
for(int i=,j=(n-k)/;i<n;i++){
if(j) cout<<,j--;
else cout<<,j=(n-k)/;
}
return ;
}

Codeforces 1159D The minimal unique substring(构造)的更多相关文章

  1. codeforces#1159D. The minimal unique substring(打表找规律+构造)

    题目链接: https://codeforces.com/contest/1159/problem/D 题意: 构造一个长度为$n$的$01$串,最小特殊连续字串的长度为$k$ 也就是,存在最小的$k ...

  2. The minimal unique substring CodeForces - 1159D (构造)

    核心观察是形如01,001,0001,...的串循环时, $n$每增长1, $k$就增长1. #include <iostream> #include <sstream> #i ...

  3. codeforces 389 D. Fox and Minimal path(构造+思维)

    题目链接:https://vjudge.net/contest/175446#problem/J 题解:显然要用最多n个点构成的图要使的得到的最短路条数有1e9次个,显然要有几个数相乘容易想到2的几进 ...

  4. Codeforces 1276C/1277F/1259F Beautiful Rectangle (构造)

    题目链接 http://codeforces.com/contest/1276/problem/C 题解 嗯,比赛结束前3min想到做法然后rush不出来了--比赛结束后又写了15min才过-- 以下 ...

  5. codeforces 477B B. Dreamoon and Sets(构造)

    题目链接: B. Dreamoon and Sets time limit per test 1 second memory limit per test 256 megabytes input st ...

  6. Codeforces Gym 100187K K. Perpetuum Mobile 构造

    K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...

  7. Codeforces 610C:Harmony Analysis(构造)

    [题目链接] http://codeforces.com/problemset/problem/610/C [题目大意] 构造出2^n个由1和-1组成的串使得其两两点积为0 [题解] 我们可以构造这样 ...

  8. Codeforces 804E The same permutation(构造)

    [题目链接] http://codeforces.com/contest/804/problem/E [题目大意] 给出一个1到n的排列,问每两个位置都进行一次交换最终排列不变是否可能, 如果可能输出 ...

  9. Codeforces 989 P循环节01构造 ABCD连通块构造 思维对云遮月参考系坐标轴转换

    A 直接判存不存在连续的三个包含A,B,C就行 /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a ...

随机推荐

  1. CSS居中完全指南——构建CSS居中决策树

    CSS居中完全指南--构建CSS居中决策树 本文总结CSS居中,包括水平居中和垂直居中.本文相当于CSS决策树,下次再遇到CSS居中问题时有章可循. 参考Centering in CSS: A Com ...

  2. Arduino库

    单总线库: 下载地址  :  链接:https://pan.baidu.com/s/1YSuqrXWuBAxMEUWHy8rckw    提取码:svix 把整个文件夹复制到 Arduino安装目录的 ...

  3. HBase设计规范(转载)

    在这里讲什么设计规范实在是有些不知天高地厚,毕竟笔者本人也只是一个大数据技术的初学者,断然不敢制订什么设计规范的,所以请原谅我的狂妄,这个设计规范,只是本人对自己制订的,与别人无关. 之前,HBase ...

  4. Win10离线安装.NET Framework 3.5的方法补充(附cab格式离线安装包下载) - 转载

    MS酋长很早以前已经分享了<Win10离线安装.NET Framework 3.5的方法技巧>,同时分享了exe格式的.NET Framework 3.5离线安装包下载地址.但有部分网友反 ...

  5. java构造方法和重写equals

    Cell的构造函数 package Test; import java.util.Objects; public class Cell { int a; int b; public int getA( ...

  6. JS&ASPDotNet_大文件上传问题

    HTML部分 <%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="index.aspx. ...

  7. HDU 2825 Wireless Password ( Trie图 && 状态压缩DP )

    题意 : 输入n.m.k意思就是给你 m 个模式串,问你构建长度为 n 至少包含 k 个模式串的方案有多少种 分析 : ( 以下题解大多都是在和 POJ 2778 && POJ 162 ...

  8. 【BZOJ5092】分割序列(高维前缀和)

    题意:对于一个长度为n的非负整数序列b_1,b_2,...,b_n, 定义这个序列的能量为:f(b)=max{i=0,1,...,n}((b_1 xor b_2 xor...xor b_i)+(b_{ ...

  9. SpringCloud 教程 (五) 断路器监控(Hystrix Dashboard)

    一.Hystrix Dashboard简介 在微服务架构中为例保证程序的可用性,防止程序出错导致网络阻塞,出现了断路器模型.断路器的状况反应了一个程序的可用性和健壮性,它是一个重要指标.Hystrix ...

  10. 【转】GLSL资料收集

    https://blog.csdn.net/u013467442/article/details/44457869 其中入门资料相当好:https://blog.csdn.net/racehorse/ ...