H-Fashion in Berland
#include <bits/stdc++.h>
using namespace std;
int a[1005];
int main()
{
int n;
scanf("%d",&n);
int sum = 0;
int flag;
for(int i = 0; i < n; i ++)
{
scanf("%d",&a[i]);
if(a[i]==0){
sum ++;
}
}
if(n == 1)
{
if(a[0] == 1)
{
flag = 1;
}
else
{
flag = 0;
}
}
else
{
if(sum==1)
{
flag = 1;
}
else
{
flag = 0;
}
}
if(flag)
printf("YES\n");
else
printf("NO\n");
return 0;
}
题目描述:
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".
Example
3
1 0 1
YES
3
1 0 0
NO
H-Fashion in Berland的更多相关文章
- Educational Codeforces Round 14 A. Fashion in Berland 水题
A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to ...
- codeforces 691A A. Fashion in Berland(水题)
题目链接: A. Fashion in Berland 题意: 思路: AC代码: //#include <bits/stdc++.h> #include <iostream> ...
- 【模拟】Codeforces 691A Fashion in Berland
题目链接: http://codeforces.com/problemset/problem/691/A 题目大意: n个数0或1,要求恰好n-1个1,如果n为1则那个数一定要是1 题目思路: [模拟 ...
- Codeforces 691A Fashion in Berland
水题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #includ ...
- Educational Codeforces Round 14
A - Fashion in Berland 水 // #pragma comment(linker, "/STACK:102c000000,102c000000") #inclu ...
- Codeforces Round #375 (Div. 2)——D. Lakes in Berland(DFS连通块)
D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #375 (Div. 2) D. Lakes in Berland dfs
D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- codeforces 644A Parliament of Berland
A. Parliament of Berland time limit per test 1 second memory limit per test 256 megabytes input stan ...
- CodeForces 164 B. Ancient Berland Hieroglyphs 单调队列
B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co ...
随机推荐
- dfs的剪枝优化
两个剪枝问题 1. 当两点的距离(需要走的步数)大于剩下的时间时 剪去 2.奇偶剪枝问题 如果起点到终点所需走的步数的奇偶性与时间奇偶性不同的时候 剪去 起点到终点步数的奇偶性的判断 首先 明确点的奇 ...
- java-websocket客户端 断线重连 注入Service问题
java版客户端: 使用开源项目java-websocket, github地址: https://github.com/TooTallNate/Java-WebSocket github上有很多示例 ...
- 利用WkHtmlToPdf,把H5 转成PDF
工具下载地址: 链接:https://pan.baidu.com/s/1TSq2WWZcvPwuIfPRHST-FA 提取码:wkx8 原理: 通过IIS访问页面,利用WkHtmlToPdf.exe, ...
- R_基础_01
R语言介绍:R是一种区分大小写的解释型语言.R中有多种数据类型,包括向量.矩阵.数据框(与数据集类似)以及列表(各种对象的集合),广泛用于数据统计. R的特点:一次交互式会话期间的所有数据对象都被保存 ...
- 这些方面做好了才能叫运营-App运营日常
现在APP的开发推广是时代的潮流,同时也是不少企业的难题.现在我们就来谈谈APP运营的一些问题. 1. 基础运营正常维护产品最日常.最普通的工作,如APP应用包在各大应用市场提交上传等,如安卓渠道,包 ...
- vue 做的tabBar组件
效果如下 调用 <tabbar :selected='selected'></tabbar> 组件 <template> <div class='tabbar ...
- 解决JAVA连接Sybase数据库查询数据乱码的问题
连接字符串加上charset=eucgb&jconnect_version=0例如:jdbc:sybase:Tds:server:port/database?charset=eucgb& ...
- Java 之 字节输出流[OutputStream]
一.字节输出流 java.io.OutputStream 抽象类是表示字节输出流的所有类的超类,将指定的字节信息写出到目的地. 该类中定义了字节输出流的基本共性功能方法. 公性方法: public v ...
- linux操作常用命令
此篇文章是根据自己经常使用的命令进行记录备忘,不断更新 防火墙(centos7) 永久开放某个端口号: firewall-cmd --zone=public --add-port=8080/tcp - ...
- 关于#error
很简单的一个东西,但是感觉使用价值没有太大.实现了以下,结果如下: 执行到#error语句的时候直接停止编译,在下面输出设定好的错误信息. 来自为知笔记(Wiz)