Logo
(追記) (追記ここまで)

18996번 - Addition 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB31133.333%

문제

Your task is a simple one -- you have to add two numbers! Unfortunately, that would be far too simple, so we had to spice things up a bit.

PAScript is a brand new script language. A script in this language consists of $k$ lines: the $i$-th of them contains two non-empty words $a_i, b_i,ドル composed of printable ASCII characters (with numbers ranging from 33ドル$ to 126ドル$). The interpreter of PAScript reads a string $s$ from the input and executes the following pseudocode:

while true:
 foundReplacement = false
 for i = 1, 2, ..., k:
 if a(i) is a substring of s:
 	 replace the leftmost occurrence of a(i) with b(i)
 foundReplacement = true
 break
 if not foundReplacement:
 break
	print(s)

Your task is to find an effective script which adds two binary numbers. The input for your script will be a string of the form binary number + binary number, without spaces and leading zeros. An example of a correct input is 10001+1001. The two binary numbers represent non-negative integers. The length of the input string does not exceed 100ドル$.

Your script should output the sum of the input numbers in binary and without leading zeros as well. For the above example the result should be 11010.

Your script should also be short and effective. Specifically, it should satisfy the following conditions:

  • $k \le 50$ (the script can have no more than 50ドル$ lines);
  • 1ドル \le |a_i|, |b_i| \le 8$ (no word in the script can have more than 8 characters nor be empty);
  • For each input, the interpreter executes the external while loop at most 100ドル,000円$ times. Moreover, during the entire execution of the script the length of $s$ never exceeds 2017ドル$ characters.

입력

There is no input for this problem.

출력

The first line of the output should contain a single number $k$ (1ドル \le k \le 50$) -- the number of lines in the script. The $i$-th of the following $k$ lines should represent the $i$-th line of the script and thus should contain two non-empty words $a_i, b_i$ separated by a single space.

제한

예제 입력 1

예제 출력 1

6
00 0
01 1
10 1
11 1
0 NO
1 YES

노트

Of course, the above example above script does not solve the task stated above. The example script, on the other hand, for a string containing zeros and ones only, finds whether it contains at least one 1ドル$.

출처

Camp > Petrozavodsk Programming Camp > Summer 2018 > Day 5: Warsaw U Contest, XVIII Open Cup named after E.V. Pankratiev Onsite I번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /