Educational Codeforces Round 14 A. Fashion in Berland 水题
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 水题的更多相关文章
- Educational Codeforces Round 4 A. The Text Splitting 水题
A. The Text Splitting 题目连接: http://www.codeforces.com/contest/612/problem/A Description You are give ...
- 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 ...
- 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 ...
- Educational Codeforces Round 13 D. Iterated Linear Function 水题
D. Iterated Linear Function 题目连接: http://www.codeforces.com/contest/678/problem/D Description Consid ...
- Educational Codeforces Round 13 C. Joty and Chocolate 水题
C. Joty and Chocolate 题目连接: http://www.codeforces.com/contest/678/problem/C Description Little Joty ...
- Educational Codeforces Round 13 B. The Same Calendar 水题
B. The Same Calendar 题目连接: http://www.codeforces.com/contest/678/problem/B Description The girl Tayl ...
- Educational Codeforces Round 13 A. Johny Likes Numbers 水题
A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes ...
- Educational Codeforces Round 12 A. Buses Between Cities 水题
A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run ...
- Educational Codeforces Round 11 B. Seating On Bus 水题
B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...
随机推荐
- bzoj千题计划186:bzoj1048: [HAOI2007]分割矩阵
http://www.lydsy.com/JudgeOnline/problem.php?id=1048 #include<cmath> #include<cstdio> #i ...
- html5 canvas 径向渐变
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- javascript模块模式
目前模块模式得到了广泛应用,因为它提供了结构化的思想并且有助于组织日益增长的代码.模块模式提供了一种创建自包含非耦合代码片段有利工具,可以将它视为黑盒功能. 板栗: var array = (func ...
- 格式化 SQL 来提高效率
本文由 伯乐在线 - cucr 翻译,黄利民 校稿.未经许可,禁止转载!英文出处:msiman.ga.欢迎加入翻译小组. 背景 已格式化的SQL并不比未格式化SQL运行地更快.数据库可能真的不太在意你 ...
- Nginx使用笔记
本篇记录使用Nginx的一些tricks. 一.更改默认Web根目录 修改配置文件 Nginx默认的Web根目录是:/usr/share/nginx/html/,一般我们都是习惯的是:/var/www ...
- Django进阶之session
基于cookie做用户验证时:敏感信息不适合放在cookie中 session依赖cookie session原理 cookie是保存在用户浏览器端的键值对 session是保存在服务器端的键值对 s ...
- C++笔试易错题集(持续更新)
1.如下代码输出结果是什么? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include<stdio.h> char *myString() { ...
- 利用gcc自带的功能-fstack-protector检测栈溢出及其实现【转】
转自:https://www.cnblogs.com/leo0000/p/5719186.html 最近又遇到了一个崩溃,栈回溯非常怪异. /lib/i386-linux-gnu/libc.so.6( ...
- 分析占用了大量CPU处理时间的是Java进程中哪个线程
下面是详细步骤: 1. 首先确定进程的 ID ,可以使用 jps -v 或者 top 命令直接查看 2. 查看该进程中哪个线程占用大量 CPU,执行 top -H -p [PID] 结果如下: 可以发 ...
- ckeditor:新增时会得到上次编辑的内容
参考网址:http://blog.sina.com.cn/s/blog_6961ba9b0102wwye.html 第一次新增时没有问题,编辑器里面内容为空,编辑数据时,也是正常,但是第二次点击新增时 ...