CF301C.Yaroslav and Algorithm

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Yaroslav likes algorithms. We'll describe one of his favorite algorithms.

  1. The algorithm receives a string as the input. We denote this input string as a.
  2. The algorithm consists of some number of command. Сommand number i looks either as s__i >> w__i, or as s__i <> w__i, where s__i and w__i are some possibly empty strings of length at most 7, consisting of digits and characters "?".
  3. At each iteration, the algorithm looks for a command with the minimum index i, such that s__i occurs in a as a substring. If this command is not found the algorithm terminates.
  4. Let's denote the number of the found command as k. In string a the first occurrence of the string s__k is replaced by string w__k. If the found command at that had form s__k >> w__k, then the algorithm continues its execution and proceeds to the next iteration. Otherwise, the algorithm terminates.
  5. The value of string a after algorithm termination is considered to be the output of the algorithm.

Yaroslav has a set of n positive integers, he needs to come up with his favorite algorithm that will increase each of the given numbers by one. More formally, if we consider each number as a string representing the decimal representation of the number, then being run on each of these strings separately, the algorithm should receive the output string that is a recording of the corresponding number increased by one.

Help Yaroslav.

亚罗斯拉夫喜欢算法。下面我们介绍他最喜爱的算法之一。

  1. 该算法以一个字符串作为输入。我们将此输入字符串记为 aa。
  2. 该算法由若干条命令组成。第 ii 条命令的形式为 si≫wis_i \gg w_i 或 si≪wis_i \ll w_i,其中 sis_i 和 wiw_i 均为长度至多为 7 的字符串(可能为空),且仅由数字字符和字符 ? 组成。
  3. 在每次迭代中,算法查找下标最小的命令 ii,使得 sis_i 作为子串出现在 aa 中。若未找到这样的命令,则算法终止。
  4. 设找到的命令编号为 kk。将字符串 aa 中 sks_k 的首次出现替换为字符串 wkw_k。若该命令形如 sk≫wks_k \gg w_k,则算法继续执行,并进入下一次迭代;否则(即命令形如 sk≪wks_k \ll w_k),算法终止。
  5. 算法终止后所得的字符串 aa 即为该算法的输出。

亚罗斯拉夫有一组 nn 个正整数。他需要设计出他最喜爱的上述算法,使得该算法能将给定的每个数均加一。更准确地说:若将每个数视作其十进制表示所对应的字符串,则当该算法分别作用于这些字符串时,对每个输入字符串所产生的输出字符串,应恰好是对应数字加一后的十进制表示。

请帮助亚罗斯拉夫。

输入格式

The first line contains integer n (1 ≤ n ≤ 100) — the number of elements in the set. The next n lines contains one positive integer each. All the given numbers are less than 1025.

第一行包含一个整数 nn(1≤n≤1001 \leq n \leq 100)—— 表示集合中元素的个数。接下来的 nn 行每行包含一个正整数。所有给定的数均小于 10251025。

输出格式

Print the algorithm which can individually increase each number of the set. In the i-th line print the command number i without spaces.

Your algorithm will be launched for each of these numbers. The answer will be considered correct if:

  • Each line will a correct algorithm command (see the description in the problem statement).
  • The number of commands should not exceed 50.
  • The algorithm will increase each of the given numbers by one.
  • To get a respond, the algorithm will perform no more than 200 iterations for each number.

输出一个算法,该算法可对集合中的每个数分别执行加一操作。在第 ii 行输出第 ii 条命令(命令之间不包含空格)。

该算法将被依次应用于给定的每个数字。当满足以下条件时,答案视为正确:

  • 每一行均为一条合法的算法指令(参见题目描述中的指令说明);
  • 指令总数不超过 50 条;
  • 该算法可使每个给定的数字均增加 1;
  • 对每个数字执行该算法时,迭代次数不超过 200 次。

输入输出样例

  • 输入#1

    2
    10
    79

    输出#1

    10&lt;&gt;11
    79&lt;&gt;80

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

首页