首页 > 代码库 > 【模拟】Codeforces 691A Fashion in Berland

【模拟】Codeforces 691A Fashion in Berland

题目链接:

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

题目大意:

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

题目思路:

  【模拟】

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

 

 

技术分享
 1 // 2 //by coolxxx 3 //#include<bits/stdc++.h> 4 #include<iostream> 5 #include<algorithm> 6 #include<string> 7 #include<iomanip> 8 #include<map> 9 #include<stack>10 #include<queue>11 #include<set>12 #include<bitset>13 #include<memory.h>14 #include<time.h>15 #include<stdio.h>16 #include<stdlib.h>17 #include<string.h>18 //#include<stdbool.h>19 #include<math.h>20 #define min(a,b) ((a)<(b)?(a):(b))21 #define max(a,b) ((a)>(b)?(a):(b))22 #define abs(a) ((a)>0?(a):(-(a)))23 #define lowbit(a) (a&(-a))24 #define sqr(a) ((a)*(a))25 #define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))26 #define mem(a,b) memset(a,b,sizeof(a))27 #define eps (1e-8)28 #define J 1029 #define mod 100000000730 #define MAX 0x7f7f7f7f31 #define PI 3.1415926535897932332 #define N 100433 using namespace std;34 typedef long long LL;35 int cas,cass;36 int n,m,lll,ans;37 bool a[N];38 int main()39 {40     #ifndef ONLINE_JUDGE41 //    freopen("1.txt","r",stdin);42 //    freopen("2.txt","w",stdout);43     #endif44     int i,j,k;45     46 //    for(scanf("%d",&cass);cass;cass--)47 //    for(scanf("%d",&cas),cass=1;cass<=cas;cass++)48 //    while(~scanf("%s",s+1))49     while(~scanf("%d",&n))50     {51         for(i=1;i<=n;i++)52             scanf("%d",&a[i]);53         if(n==1)54         {55             if(a[1])puts("YES");56             else puts("NO");57             continue;58         }59         for(i=1,j=0;i<=n;i++)60             if(!a[i])j++;61         if(j!=1)puts("NO");62         else puts("YES");63     }64     return 0;65 }66 /*67 //68 69 //70 */
View Code

 

【模拟】Codeforces 691A Fashion in Berland