CF1181B.Split a Number

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

Dima worked all day and wrote down on a long paper strip his favorite number nn consisting of ll digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.

To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive integer without leading zeros. After that he will compute the sum of the two integers and write it down on a new strip.

Dima wants the resulting integer to be as small as possible, because it increases the chances that the sum will fit it in the bookshelf. Help Dima decide what is the minimum sum he can obtain.

迪马工作了一整天,并在一条很长的纸带上写下了他最喜欢的、由 ll 位数字组成的数 nn。不幸的是,这条纸带太长了,无法放进迪马的书架中。

为了解决这个问题,迪马决定将纸带切成两段非空的部分,使得每一段都表示一个不含前导零的正整数。然后,他将计算这两个整数的和,并将该和写在一条新的纸带上。

迪马希望最终得到的整数尽可能小,因为这样更有可能使该和能放进书架中。请帮助迪马确定他能得到的最小和。

输入格式

The first line contains a single integer ll (2≤l≤100 0002 \le l \le 100\,000) — the length of the Dima's favorite number.

The second line contains the positive integer nn initially written on the strip: the Dima's favorite number.

The integer nn consists of exactly ll digits and it does not contain leading zeros. Dima guarantees, that there is at least one valid way to split the strip.

第一行包含一个整数 ll(2≤l≤100 0002 \le l \le 100\,000)——即迪马最喜爱数字的长度。

第二行包含最初写在纸条上的正整数 nn:即迪马最喜爱的数字。

整数 nn 恰好由 ll 位数字组成,且不包含前导零。迪马保证,至少存在一种合法的方式将该纸条进行分割。

输出格式

Print a single integer — the smallest number Dima can obtain.

输出一个整数——Dima 能得到的最小数字。

输入输出样例

  • 输入#1

    7
    1234567

    输出#1

    1801
  • 输入#2

    3
    101

    输出#2

    11

说明/提示

In the first example Dima can split the number 12345671234567 into integers 12341234 and 567567. Their sum is 18011801.

In the second example Dima can split the number 101101 into integers 1010 and 11. Their sum is 1111. Note that it is impossible to split the strip into "1" and "01" since the numbers can't start with zeros.

在第一个例子中,迪马可以将数字 12345671234567 拆分为整数 12341234 和 567567,它们的和为 18011801。

在第二个例子中,迪马可以将数字 101101 拆分为整数 1010 和 11,它们的和为 1111。注意,不能将该数字拆分为 “1” 和 “01”,因为数字不能以 00 开头。

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

首页