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. dp的进阶 (一)

    熟练掌握dp的定义方法. ①四维dp的转移,生命值转移时候需要注意的 ②集合的定义,判断二进制内部是否有环 ③很难想到的背包问题 ④博弈类型的dp ⑤排列组合类型dp ⑥01背包的变种(01背包+完全 ...

  2. [转载]Cross-Platform Development in Visual Studio

    http://msdn.microsoft.com/en-us/library/dn771552.aspx http://www.cnblogs.com/mengkzhaoyun/p/4152823. ...

  3. mysql 创建用户自定义函数

    为了防止分号产生的中途输出,自己定义一个 分隔符,这里仿照mysql官方的例子:使用两个美元符号 $$ 作为分割符号,下面这段代码就是创建一个自定义mysql函数的原型了,可以在这个基础上修改,这样, ...

  4. Zookeeper笔记之quota

    一.节点配额概述 zookeeper中可以往节点存放数据,但是一般来说存放数据总是要有个度量的对吧,不然空间就那么大,如果某个节点将空间全占用了其它节点没得用了,所以zookeeper提供了一个对节点 ...

  5. linux中serial driver理解【转】

    转自:http://blog.csdn.net/laoliu_lcl/article/details/39967225 英文文档地址:myandroid/kernel_imx/Documentatio ...

  6. Ansible Tower系列 四(使用tower执行一个命令)【转】

    在主机清单页面中,选择一个主机清单,进入后,选择hosts里的主机 Paste_Image.png 点击 RUN COMMANDS MODULE 选择 commandARGUMENTS 填写 ifco ...

  7. springcloud Zuul中路由配置细节

    上篇文章我们介绍了API网关的基本构建方式以及请求过滤,小伙伴们对Zuul的作用应该已经有了一个基本的认识,但是对于路由的配置我们只是做了一个简单的介绍,本文我们就来看看路由配置的其他一些细节. 首先 ...

  8. 洛谷 2257 - YY的GCD

    莫比乌斯反演半模板题 很容易可以得到 \[Ans = \sum\limits_{p \in prime} \sum\limits_{d = 1}^{\min (\left\lfloor\frac{a} ...

  9. !!!sql_mode=only_full_group_by配置

    Expression #7 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'invoicecer ...

  10. Android BLE设备蓝牙通信框架BluetoothKit

    BluetoothKit是一款功能强大的Android蓝牙通信框架,支持低功耗蓝牙设备的连接通信.蓝牙广播扫描及Beacon解析. 关于该项目的详细文档请关注:https://github.com/d ...