• 【模拟】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 10
    29 #define mod 1000000007
    30 #define MAX 0x7f7f7f7f
    31 #define PI 3.14159265358979323
    32 #define N 1004
    33 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_JUDGE
    41 //    freopen("1.txt","r",stdin);
    42 //    freopen("2.txt","w",stdout);
    43     #endif
    44     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
  • 相关阅读:
    【思维导图】前端开发JavaScript-巩固你的JavaScript知识体系
    前端面试日更解答 2020-03-28
    CSS基础知识
    HTML基础知识
    Web页面制作基础
    前端面试日更解答 2020-03-24
    前端面试日更解答 2020-03-23
    前端面试日更解答 2020-03-22
    前端面试日更解答 2020-03-21
    前端面试日更解答 2020-03-20
  • 原文地址:https://www.cnblogs.com/Coolxxx/p/5814110.html
Copyright © 2020-2023  润新知