您的位置:首页 > 其它

【模拟】Codeforces 691A Fashion in Berland

2016-08-27 23:45 204 查看
题目链接:

  http://codeforces.com/problemset/problem/691/A


题目大意:

  n个数0或1,要求恰好n-1个1,如果n为1则那个数一定要是1

题目思路:

  【模拟】

  水题一道。看错题目两次。。

//
//by coolxxx
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define mem(a,b) memset(a,b,sizeof(a))
#define eps (1e-8)
#define J 10
#define mod 1000000007
#define MAX 0x7f7f7f7f
#define PI 3.14159265358979323
#define N 1004
using namespace std;
typedef long long LL;
int cas,cass;
int n,m,lll,ans;
bool a
;
int main()
{
#ifndef ONLINE_JUDGE
//    freopen("1.txt","r",stdin);
//    freopen("2.txt","w",stdout);
#endif
int i,j,k;

//    for(scanf("%d",&cass);cass;cass--)
//    for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
//    while(~scanf("%s",s+1))
while(~scanf("%d",&n))
{
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
if(n==1)
{
if(a[1])puts("YES");
else puts("NO");
continue;
}
for(i=1,j=0;i<=n;i++)
if(!a[i])j++;
if(j!=1)puts("NO");
else puts("YES");
}
return 0;
}
/*
//

//
*/


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: