A. Fashion in Berland

题目连接:

http://www.codeforces.com/contest/691/problem/A

Description

According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened, so the jacket will not swinging open.

You are given a jacket with n buttons. Determine if it is fastened in a right way.

Input

The first line contains integer n (1 ≤ n ≤ 1000) — the number of buttons on the jacket.

The second line contains n integers ai (0 ≤ ai ≤ 1). The number ai = 0 if the i-th button is not fastened. Otherwise ai = 1.

Output

In the only line print the word "YES" if the jacket is fastened in a right way. Otherwise print the word "NO".

Sample Input

3

1 0 1

Sample Output

YES

Hint

题意

给你n个数,如果数只有1个的话,那就这个数必须是1,否则的话,就必须只有一个0

题解:

水题

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int main(){
int n;
scanf("%d",&n);
int num1 = 0,num2 = 0;
for(int i=1;i<=n;i++){
int x;
scanf("%d",&x);
if(x==1)num1++;
else num2++;
}
if(num1+num2==1&&num1==1){
return puts("YES");
}else if(num1+num2>1&&num2==1){
return puts("YES");
}
puts("NO");
}

Educational Codeforces Round 14 A. Fashion in Berland 水题的更多相关文章

  1. Educational Codeforces Round 4 A. The Text Splitting 水题

    A. The Text Splitting 题目连接: http://www.codeforces.com/contest/612/problem/A Description You are give ...

  2. Codeforces Educational Codeforces Round 3 B. The Best Gift 水题

    B. The Best Gift 题目连接: http://www.codeforces.com/contest/609/problem/B Description Emily's birthday ...

  3. Codeforces Educational Codeforces Round 3 A. USB Flash Drives 水题

    A. USB Flash Drives 题目连接: http://www.codeforces.com/contest/609/problem/A Description Sean is trying ...

  4. Educational Codeforces Round 13 D. Iterated Linear Function 水题

    D. Iterated Linear Function 题目连接: http://www.codeforces.com/contest/678/problem/D Description Consid ...

  5. Educational Codeforces Round 13 C. Joty and Chocolate 水题

    C. Joty and Chocolate 题目连接: http://www.codeforces.com/contest/678/problem/C Description Little Joty ...

  6. Educational Codeforces Round 13 B. The Same Calendar 水题

    B. The Same Calendar 题目连接: http://www.codeforces.com/contest/678/problem/B Description The girl Tayl ...

  7. Educational Codeforces Round 13 A. Johny Likes Numbers 水题

    A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes ...

  8. Educational Codeforces Round 12 A. Buses Between Cities 水题

    A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run ...

  9. Educational Codeforces Round 11 B. Seating On Bus 水题

    B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...

随机推荐

  1. bzoj千题计划180:bzoj4411: [Usaco2016 Feb]Load balancing

    http://www.lydsy.com/JudgeOnline/problem.php?id=4411 用树状数组维护扫描线 一个树状数组维护扫描线之上的y<=i点,另一个维护扫描线之下y&l ...

  2. [整理].net中的延迟初始化器

    LazyInitializer类 private void EnsureInitialized() { LazyInitializer.EnsureInitialized(ref _initializ ...

  3. HTML5 中 Geolocation 获取地理位置的原理是什么?

    http://www.zhihu.com/question/20473051?sort=created geolocation的位置信息来源包括GPS.IP地址.RFID.WIFI和蓝牙的MAC地址. ...

  4. [原]Android 初遇Http错误 httpClient.execute

    错误源头: HttpResponse response = httpClient.execute(httpget); 错误信息: android.os.NetworkOnMainThreadExcep ...

  5. centos安装lrzsz

    yum -y install lrzsz 使用rz打开上传框

  6. Servlet笔记11--补充

    Servlet线程安全问题: 代码示例: package com.bjpowernode.javaweb.servlet; import java.io.IOException; import jav ...

  7. python3之模板pycurl探测web服务质量

    1.pycurl简介 pycURL是libcurl多协议文件传输库的python接口,与urllib模块类似,PycURL可用于从python程序中获取由URL标识的对象,功能很强大,libcurl速 ...

  8. BAT获取FTP指定文件

    以下两个文件放在同一目录下 getfile.bat文件内容如下: @echo offftp.exe -i -s:getfile.txt 192.168.1.2(更换成你的ip,参数之间有空格)paus ...

  9. Linux系统的快速启动机制(内核切换) 【转】

    转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=26807463&id=4187846 原文地址:Linux系统的 ...

  10. 【译】在Asp.Net Core 中使用外部登陆(google、微博...)

    原文出自Rui Figueiredo的博文<External Login Providers in ASP.NET Core> (本文很长) 摘要:本文主要介绍了使用外部登陆提供程序登陆的 ...