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

本文共 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

你可能感兴趣的文章
新手也能轻松掌握的分布式系统「事务」技巧
查看>>
iOS开发之使用Git的基本使用(一)
查看>>
配置云存储网关在线服务支持多个互联VPC-高速通道版
查看>>
6个步骤从头开始编写机器学习算法:感知器案例研究
查看>>
NCalc 学习笔记 (三)
查看>>
NetBeans 成为 Apache 软件基金会顶级项目
查看>>
SSRF在Redis中反弹shell
查看>>
UML关系图
查看>>
SpringBoot 手写切片/面向切面编程
查看>>
动态 Web Server 技术发展历程
查看>>
使用pymysql(使用一)
查看>>
Redisson 3.10.6 发布,Redis 客户端
查看>>
日志框架 - 基于spring-boot - 使用入门
查看>>
用libtommath实现RSA算法
查看>>
基于POLARDB数据库的压测实践
查看>>
通过工具SecureCRTPortable将项目部署到服务器上
查看>>
利用QRCode实现待logo的二维码的创建
查看>>
【云周刊】第190期:阿里云超算揭秘:虚拟机的心脏,物理机的肌肉
查看>>
崩溃bug日志总结3
查看>>
推荐一个有趣的Chrome扩展程序-查看任意网站的开发技术栈
查看>>