CF146A.Lucky Ticket
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya loves tickets very much. As we know, each ticket has a number that is a positive integer. Its length equals n (n is always even). Petya calls a ticket lucky if the ticket's number is a lucky number and the sum of digits in the first half (the sum of the first n / 2 digits) equals the sum of digits in the second half (the sum of the last n / 2 digits). Check if the given ticket is lucky.
佩蒂亚非常喜爱幸运数字。众所周知,幸运数字是指十进制表示中仅包含幸运数字 4 和 7 的正整数。例如,47、744、4 是幸运数字,而 5、17、467 则不是。
佩蒂亚也非常喜爱车票。众所周知,每张车票都有一个编号,该编号是一个正整数,其长度为 n(n 恒为偶数)。佩蒂亚称一张车票为幸运车票,当且仅当该车票的编号是一个幸运数字,且前半部分数字之和(即前 n/2 位数字之和)等于后半部分数字之和(即后 n/2 位数字之和)。请判断给定的车票是否为幸运车票。
输入格式
The first line contains an even integer n (2 ≤ n ≤ 50) — the length of the ticket number that needs to be checked. The second line contains an integer whose length equals exactly n — the ticket number. The number may contain leading zeros.
第一行包含一个偶数整数 n(2 ≤ n ≤ 50)——即需要检查的票号的长度。
第二行包含一个长度恰好为 n 的整数——即票号。该数字可能包含前导零。
输出格式
On the first line print "YES" if the given ticket number is lucky. Otherwise, print "NO" (without the quotes).
如果给定的车票号码是幸运号码,则在第一行输出 “YES”;否则输出 “NO”(不带引号)。
输入输出样例
输入#1
2 47
输出#1
NO
输入#2
4 4738
输出#2
NO
输入#3
4 4774
输出#3
YES
说明/提示
In the first sample the sum of digits in the first half does not equal the sum of digits in the second half (4 ≠ 7).
In the second sample the ticket number is not the lucky number.
在第一个样例中,前半部分数字之和不等于后半部分数字之和(4 ≠ 7)。
在第二个样例中,该票号不是幸运号码。
输入解题思路,AI测评打分。不知道怎么写?