CF1030C.Vasya and Golden Ticket

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Recently Vasya found a golden ticket — a sequence which consists of nn digits a1a2ana_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.

输入格式

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

The second line contains nn digits a1a2ana_1 a_2 \dots a_n ( 0ai90 \le a_i \le 9 ) — the golden ticket. Digits are printed without spaces.

输出格式

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

输入输出样例

  • 输入#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.

首页