CF1030C.Vasya and Golden Ticket

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Recently Vasya found a golden ticket — a sequence which consists of nn digits a1a2…ana_1a_2\dots a_n. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket 350178350178 is lucky since it can be divided into three segments 350350, 1717 and 88: 3+5+0=1+7=83+5+0=1+7=8. Note that each digit of sequence should belong to exactly one segment.

Help Vasya! Tell him if the golden ticket he found is lucky or not.

最近,瓦西娅发现了一张“金票”——一个由 nn 个数字组成的序列 a1a2…ana_1a_2\dots a_n。瓦西娅认为一张票是幸运的,当且仅当它可以被划分为两个或更多个互不相交的段,且这些段的数字之和均相等。例如,票 350178350178 是幸运的,因为它可以被划分为三个段:350350、1717 和 88,满足 3+5+0=1+7=83+5+0 = 1+7 = 8。注意:序列中的每个数字必须且只能属于一个段。

请帮助瓦西娅!告诉他,他找到的这张金票是否幸运。

输入格式

The first line contains one integer nn (2≤n≤1002 \le n \le 100) — the number of digits in the ticket.

The second line contains nn digits a1a2…ana_1 a_2 \dots a_n (0≤ai≤90 \le a_i \le 9) — the golden ticket. Digits are printed without spaces.

第一行包含一个整数 nn(2≤n≤1002 \le n \le 100)—— 表示车票的位数。

第二行包含 nn 个数字 a1a2…ana_1 a_2 \dots a_n(0≤ai≤90 \le a_i \le 9)—— 表示这张金色车票。数字之间不包含空格。

输出格式

If the golden ticket is lucky then print "YES", otherwise print "NO" (both case insensitive).

如果金券是幸运的,则输出 “YES”,否则输出 “NO”(均不区分大小写)。

输入输出样例

  • 输入#1

    5
    73452

    输出#1

    YES
  • 输入#2

    4
    1248

    输出#2

    NO

说明/提示

In the first example the ticket can be divided into 77, 3434 and 5252: 7=3+4=5+27=3+4=5+2.

In the second example it is impossible to divide ticket into segments with equal sum.

在第一个例子中,这张票可以被划分为 77、3434 和 5252:7=3+4=5+27=3+4=5+2。

在第二个例子中,无法将这张票划分为若干段,使得各段数字之和相等。

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

首页