CF1492D.Genius's Gambit

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given three integers aa, bb, kk.

Find two binary integers xx and yy (x≥yx \ge y) such that

  1. both xx and yy consist of aa zeroes and bb ones;
  2. x−yx - y (also written in binary form) has exactly kk ones.

You are not allowed to use leading zeros for xx and yy.

给你三个整数 aa、bb、kk。

请找出两个二进制整数 xx 和 yy(满足 x≥yx \ge y),使得:

  1. xx 和 yy 均恰好由 aa 个零和 bb 个一组成;
  2. x−yx - y(以二进制形式表示)恰好包含 kk 个一。

不允许在 xx 和 yy 中使用前导零。

输入格式

The only line contains three integers aa, bb, and kk (0≤a0 \leq a; 1≤b1 \leq b; 0≤k≤a+b≤2⋅1050 \leq k \leq a + b \leq 2 \cdot 10^5) — the number of zeroes, ones, and the number of ones in the result.

唯一的一行包含三个整数 aa、bb 和 kk(满足 0≤a0 \leq a;1≤b1 \leq b;0≤k≤a+b≤2⋅1050 \leq k \leq a + b \leq 2 \cdot 10^5),分别表示零的个数、一的个数,以及结果中一的个数。

输出格式

If it's possible to find two suitable integers, print "Yes" followed by xx and yy in base-2.

Otherwise print "No".

If there are multiple possible answers, print any of them.

如果能找到两个合适的整数,则输出“Yes”,后跟以二进制表示的 xx 和 yy。
否则输出“No”。
如果有多个可能的答案,输出任意一个即可。

输入输出样例

  • 输入#1

    4 2 3

    输出#1

    Yes
    101000
    100001
  • 输入#2

    3 2 1

    输出#2

    Yes
    10100
    10010
  • 输入#3

    3 2 5

    输出#3

    No

说明/提示

In the first example, x=1010002=25+23=4010x = 101000_2 = 2^5 + 2^3 = 40_{10}, y=1000012=25+20=3310y = 100001_2 = 2^5 + 2^0 = 33_{10}, 4010−3310=710=22+21+20=111240_{10} - 33_{10} = 7_{10} = 2^2 + 2^1 + 2^0 = 111_{2}. Hence x−yx-y has 33 ones in base-2.

In the second example, x=101002=24+22=2010x = 10100_2 = 2^4 + 2^2 = 20_{10}, y=100102=24+21=18y = 10010_2 = 2^4 + 2^1 = 18, x−y=20−18=210=102x - y = 20 - 18 = 2_{10} = 10_{2}. This is precisely one 1.

In the third example, one may show, that it's impossible to find an answer.

在第一个例子中,x=1010002=25+23=4010x = 101000_2 = 2^5 + 2^3 = 40_{10},y=1000012=25+20=3310y = 100001_2 = 2^5 + 2^0 = 33_{10},4010−3310=710=22+21+20=111240_{10} - 33_{10} = 7_{10} = 2^2 + 2^1 + 2^0 = 111_{2}。因此 x−yx-y 在二进制表示下含有 33 个 11。

在第二个例子中,x=101002=24+22=2010x = 10100_2 = 2^4 + 2^2 = 20_{10},y=100102=24+21=18y = 10010_2 = 2^4 + 2^1 = 18,x−y=20−18=210=102x - y = 20 - 18 = 2_{10} = 10_{2}。这恰好含有一个 11。

在第三个例子中,可以证明不存在满足条件的答案。

输入解题思路,AI测评打分。不知道怎么写?

首页