博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CodeForces 146A Lucky Ticket
阅读量:7013 次
发布时间:2019-06-28

本文共 1730 字,大约阅读时间需要 5 分钟。

Lucky Ticket
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit     

Description

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.

Input

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.

Output

On the first line print "YES" if the given ticket number is lucky. Otherwise, print "NO" (without the quotes).

Sample Input

Input
2 47
Output
NO
Input
4 4738
Output
NO
Input
4 4774
Output
YES

Hint

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.

1 #include 
2 #include
3 #include
4 using namespace std; 5 int main() 6 { 7 char a[105]; 8 int i,j,n; 9 while(scanf("%d",&n)!=EOF)10 {11 int flg=1,s1=0,s2=0;12 scanf("%s",a);13 for(i=0;i
View Code

 

转载于:https://www.cnblogs.com/cyd308/p/4771482.html

你可能感兴趣的文章
我的失败与伟大 —— 上市之后的规划
查看>>
【Spark Summit East 2017】不必犹豫,使用Spark 2.0结构化流
查看>>
HTTPFS: 基于HTTP操作hadoop hdfs文件系统
查看>>
使用jquery获取父元素或父节点的方法
查看>>
如何让双十一数据大屏讲出故事?设计有口诀
查看>>
浮窗系列之窗口与用户输入系统
查看>>
swing效果点击下拉框自动填充文本框
查看>>
UML之活动图
查看>>
Shiro的Demo示例
查看>>
RISC领域ARM不是唯一
查看>>
数据库容灾的最高境界
查看>>
spark命令
查看>>
mysql explain中的select tables optimized away---(二)
查看>>
安装PHP5和PHP7
查看>>
邹承鲁院士谈学术文献阅读
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
android模仿铃声选择功能
查看>>
我的友情链接
查看>>