Binary String Constructing

手把手教你为FPGA项目集成HyperRAM IP核:从AXI接口封装到上板调试全流程 本文详细介绍了如何为FPGA项目集成HyperRAM IP核,涵盖从AXI接口封装到上板调试的全流程。通过对比DDR3L、PSRAM和HyperRAM的性能指标,突出HyperRAM在低功耗和小封装尺寸方面的优势,并提供硬件连接、AXI4-Lite接口设计、状态机优化及调试技巧等实用内容,帮助开发者高效完成FPGA项目中的内存扩展。 阅读详情

You are given three integers a, b and x. Your task is to construct a binary string s of length n=a+b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1≤i<n) such that si≠si+1

. It is guaranteed that the answer always exists.

For example, for the string "01010" there are four indices i

such that 1≤i<n and si≠si+1 (i=1,2,3,4). For the string "111001" there are two such indices i (i=3,5

).

Recall that binary string is a non-empty sequence of characters where each character is either 0 or 1.

Input

The first line of the input contains three integers a

, b and x (1≤a,b≤100,1≤x<a+b)

.

Output

Print only one string s

, where s is any binary string satisfying conditions described above. It is guaranteed that the answer always exists.

Examples

Input

2 2 1

Output

1100

Input

3 3 3

Output

101100

Input

5 3 6

Output

01010100

题意:给你a个0,b个1,让你构造用这些数字构造一个序列,并且满足以下条件:

相邻两个数不同的个数为x

 

感觉自己写的很复杂。

先分两种情况:

1,0的个数比1的个数大

2,   1的个数比0的个数大

 

在每种情况下,把01(10)看成一组,先尽可能的多放,只到x的值为 1 或 2 时;

首先放一组 01(10)只会消耗x 1点,之后再放一组01  (10)才会消耗x 2点

 

当x的值为2时,有两种情况

1,之前放了几组01  (10),此时只需把剩下的0  (1)全部放上,再把剩下的1   (0)全部放上

2,之前一组01   (10)都没放 ,此时需要先放一组01   (10),则x又消耗一点了,此时x为1,   再把剩下的1  (0)全部放上

之后把剩下的0  (1)全部放上

 

当x的值为1时 ,把剩下的1  (0)全部放上 ,  之后把剩下的0  (1)全部放上

 

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <vector>
#include <numeric>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define  eps 1e-8
#define  PI acos(-1)
#define  INF 0x3f3f3f3f
using namespace std;
const int N=1010;
typedef long long  LL;
const int dir[4][2]= { {1,0},{0,1},{-1,0},{0,-1} };

int GCD(int a,int b)
{
    return b ? GCD(b,a%b) : a;
}

int main()
{
    int i,b,j,k,x,a,l;
    cin>>a>>b>>x;

    if(a>b)
    {
        int flag=0;
        while(x>2)
        {
            if(flag==0)
            {
                printf("01");
                a--;
                b--;
                x--;
                flag=1;
                continue;
            }
            printf("01");
            a--;
            b--;
            x-=2;
        }
        if(x==2)
        {
            if(flag==0)
            {
                printf("01");
                a--;
                b--;
                for(i=0; i<b; i++)
                    printf("1");
                for(i=0; i<a; i++)
                    printf("0");
            }
            else
            {
                for(i=0; i<a; i++)
                    printf("0");
                for(i=0; i<b; i++)
                    printf("1");
            }

        }
        if(x==1)
        {
            for(i=0; i<b; i++)
                printf("1");
            for(i=0; i<a; i++)
                printf("0");
        }
    }
    else
    {
        int flag=0;
        while(x>2)
        {
            if(flag==0)
            {
                printf("10");
                a--;
                b--;
                x--;
                flag=1;
                continue;
            }
            printf("10");
            a--;
            b--;
            x-=2;
        }
        if(x==1)
        {
            for(i=0; i<a; i++)
                printf("0");
            for(i=0; i<b; i++)
                printf("1");
        }
        if(x==2)
        {
            if(flag==0)
            {
                printf("10");
                a--;
                b--;
                for(i=0; i<a; i++)
                    printf("0");
                for(i=0; i<b; i++)
                    printf("1");
            }
            else
            {
                for(i=0; i<b; i++)
                    printf("1");
                for(i=0; i<a; i++)
                    printf("0");
            }
        }
    }
    printf("\n");
    return 0;
}

 

RK3568移植AP6256 本文主要是记录RK3568移植正基的AP6256的WIFIBT模块,感兴趣的朋友可以一起学习!!!提示:以下是本篇文章正文内容,下面案例可供参考。 阅读详情

相关推荐

【雷达图】R语言绘制雷达图(ggradar),NBA季后赛数据为例

一起用R语言给nba球星画球技雷达图吧!

池塘春草梦的博客 6252

Binary String Constructing CodeForces - 1003B

You are given three integers aa, bb and xx. Your task is to construct a binary string ssof length n=a+bn=a+b such that there are exactly aa zeroes, exactly bb ones and exactlyxx indices ii (where 1≤i&...

七九河开的博客 279

瑞萨RA6M4平台I2C驱动移植实战:MPU6050传感器集成指南

本文详细介绍了在瑞萨RA6M4平台上进行I2C驱动移植并集成MPU6050传感器的实战指南。通过FSP配置工具添加I2C主栈,适配MPU6050官方驱动,实现传感器数据读取与调试,为嵌入式开发提供完整的解决方案。

banana的博客 109

Binary String Constructing (CodeForces - 1003B) (a个0,b个1,组成字符串,x个si≠si+1)

                                               Binary String Constructing                                                                           time limit per test 1 second                      ...

青笙尽_ 328

PG-FP6编程器错误代码解析与高效排障实战指南

在嵌入式系统开发与量产烧录中,编程器是连接开发环境与目标硬件的重要桥梁。其工作原理是通过特定的通信协议(如UART、SWD)与微控制器(MCU)建立连接,完成程序代码的写入、擦除与校验。这项技术的核心价值在于确保固件能够准确、可靠地部署到硬件中,是产品从原型到量产的关键环节。在实际的工程实践中,尤其是在使用瑞萨(Renesas)PG-FP6这类编程器进行调试或批量生产时,工程师常会遇到各种通信失败、编程验证错误或电源异常等问题,这些问题往往以特定的错误代码形式呈现。深入理解这些错误代码背后的硬件连接、电源时

weixin_34387468的博客 579

开源DIY龙门架:从零构建可编程运动控制平台

运动控制是自动化与机器人技术的核心基础,它通过精确指令驱动执行机构,实现物体的定位与轨迹规划。其原理通常涉及控制器、驱动器、电机与传动机构的协同工作,核心价值在于将数字指令转化为精准的物理运动,从而解放人力并提升作业一致性。在工业自动化、桌面制造(如3D打印、激光雕刻)及教育机器人等领域应用广泛。本文聚焦于一个具体的工程实践案例:使用**铝型材**、**3D打印**零件、Arduino控制器及步进电机,从机械结构设计、电路连接到代码编写,手把手教你打造一个模块化、可扩展的开源龙门架系统。该系统不仅成本可控,

weixin_33168937的博客 615

Binary Strings

Binary Strings 题目描述: 这个题目讲述的是,给定两个字符串和,这两个字符串由0和1组成,给定了两个操作,第一个操作是可以将字符串的最后一个字符移到字符串的最前面,第二个操作是可以将连续的两个字符反转,这个题目是将第一个字符和最后一个字符视为连续,然后题目问我们最少可以用多...

qq_36679229的博客 683

AI 模型训练核心方法论:零基础也能落地的 8 个关键阶段

本文是为 AI 零基础学习者打造的模型训练入门指南,以生活化语言拆解核心概念,规避专业术语壁垒。内容先通俗阐释模型训练、监督学习、数据集划分等基础概念,再按问题定义、数据准备、模型选择、环境搭建、训练、评估、调参、部署 8 个阶段,拆解完整训练流程,搭配 PyTorch 代码示例与实战案例,同时提供资源预算、常见问题解决方案及学习路径。指南强调数据的核心重要性,推荐新手优先使用迁移学习和免费 GPU 资源,兼顾理论与实操,帮助学习者快速上手,避开训练误区,独立完成从模型搭建到部署的全流程。

weixin_52741870的博客 468

binary string

dad

yundan12的博客 427

推荐系统[八]算法实践总结V3:重排在快手短视频推荐系统中的应用and手淘信息流多兴趣多目标重排技术

快手推荐系统包括了传统的召回、粗排、精排、Learning To Rank 的多目标排序、多目标预估等技术环节。而在这些模块之后的技术环节就属于重排序,主要包括手机端和服务端两部分。服务端通过传统服务器部署重排服务,包括序列重排、多源内容混排、多样性模块。端上部分包括端上重排模型和端上重排策略两部分。重排技术是快手十分重要的技术环节,它的发展速度远快于其他排序环节,属于较新的技术范畴。整个序列的价值并非单 item 效果的累计,如何使得序列价值最大化;

丨汀、的博客 1061

【AI大模型:前沿】46、AI+无人机:智能飞行革命全景指南——从技术突破到行业应用与未来趋势

AI+无人机的融合不仅是技术迭代,更是“空间生产力”的革命——它将人类活动范围从地面拓展至低空,重构物流、农业、应急等行业的生产方式。当前,技术突破(如多模态感知、群体智能)与法规松绑(超视距飞行许可)正加速产业化,预计2030年全球低空经济市场规模将突破万亿美元。技术层:轻量化AI模型、边缘-云端协同、安全冗余系统;应用层:垂直领域解决方案(如电网AI巡检、精准农业);生态层:无人机巢建设、空管系统、数据服务平台。

2025博客之星Top81。专注AI工程化与架构实战。从分布式思维到模型部署,用工程化视角为你厘清AI落地的真实路径。 5589

Binary String Constructing(思维+构造)

Binary String Constructing 题意: 给出a,b,x,构造一个01串,有a个0,b个1。这个01串刚好有x个 aiaia_i 使得ai!=ai+1。ai!=ai+1。a_i!=a_i+1。即相邻位不同 分析: 对于x,我们很容易就可以想到先输出x2x2\frac{x}{2}对0和1(n对0和1交错出现可以提供2*n-1个符合题意的aiaia_i),然后将剩余的0...

codeswarrior的博客 505

A.特定领域知识图谱知识推理方案:知识图谱推理算法综述[五]-GeniePath会自动过滤多度“邻居“的图神经网络算法。

构图对于GNN格外重要。那么怎样构图才有信息、有意义呢?如果节点的邻居只有自己,即邻接矩阵为对角阵时,GNN会退化成一个DNN模型。图中每个节点都是孤立的,相当图信息并不能相比其他方法带来增益。如果图特别稠密,比如是一个clique,即每个节点都和所有其他节点有边连接。同样的,这样的图信息同样是信息熵为0。经验上讲,节点度分布有区分度的图是相对有价值的。查看图的节点度分布。比如二类分类,分析正负例的图拓扑当然,构图和实际场景强相关。

丨汀、的博客 437

B - Binary String Constructing

You are given three integers a, b and x. Your task is to construct a binary string s of length n=a+b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1≤i&lt;n) such ...

qq_41524782的博客 489

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

B. Binary String Constructing

B. Binary String Constructing time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given three integers aa, bb and xx. Your tas...

x_flyx的博客 447

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Codeforces 1003 B Binary String Constructing

B. Binary String Constructing time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given three integers aa, bb and xx. Your tas...

swqeaaa的博客 234

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

CodeForces - 1003B Binary String Constructing

B. Binary String Constructing time limit per test1 second memory limit per test256 megabytes You are given three integers a, b and x. Your task is to construct a binary string s of length n=a+b such that there are exactly a zeroes, exactly b ones and exact

海岛Blog 1758

codeforces 1003 Binary String Constructing

http://www.elijahqi.win/archives/3913 我是先构造了 0,1,0,1的情况尝试满足条件 然后再分类讨论的 #include&lt;bits/stdc++.h&gt; using namespace std; inline char gc(){ static char now[1&lt;&lt;16],*S,*T; if (T==S){T=(S...

Elijahqi 383

【思维题】CodeForce 1003B Binary String Constructing

这段时间要沉迷刷题一段时间了,就让优快云陪我一起吧! 一、题目大意 题目意思就是给定三个数a,b,x,其中a表示待构造的字符串中有a个0,b表示待构造的字符串中有b个1,x表示待构造的字符串有x次跳转('01’和’10’称为一次跳转)。 二、题目思路以及AC代码 我发觉codeforce上题目的难度分数真的很准,1500以下,怎样都能想出来,1800以上就死费脑筋还不一定有思路… 其实我就是...

Johnson的博客 444

CodeForces 1003B Binary String Constructing

题目:点击打开链接题意:求一个含有a个0,b个1,x个相邻位置数字不相同的字符串。分析:构造题,暴力模拟。先用01交替,相邻不同的位置个数为x-1,然后把剩余的01放上去使得答案为x。第一个数可能是1,也可能是0,都要计算。代码写的太搓了,还被hack了。。。后面改进了下。代码:#pragma comment(linker, "/STACK:102400000,102400000")///手动扩栈...

常胜将军的博客 495

1003B. Binary String Constructing

You are given three integers a, b and x. Your task is to construct a binary string s of length n=a+b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1≤i&lt;n) such ...

码农的一亩三分地 293

1003B - Binary String Constructing

B. Binary String Constructingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three integers aa, bb and xx. Your task is to construct ...

memory_qianxiao的博客 547

Binary String Constructing(cf)

time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given three integers aa, bb and xx. Your task is to construct a binary stri...

代码行 187

Binary String Constructing CodeForces - 1003B (构造)

B. Binary String Constructingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three integers aa, bb and xx. Your task is to construct ...

JiaYao的博客 1180

【字符串模拟】Binary String Constructing

7/31下午暑假训练1的题解(Codeforces Round #496 (Div. 3))【CF1003B】  公式会有乱码,我就直接粘贴图片了。 Examples Input 2 2 1 Output 1100 Input 3 3 3 Output 101100 Input 5 3 6 Output 01010100 Note All...

于衡的博客 475
上一篇: c++ STL容器 vector 的使用
下一篇: map 容器的说明和使用技巧
codertcm
博客等级 码龄8年 80粉丝 98原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值