zoukankan      html  css  js  c++  java
  • ZOJ3959 Problem Preparation

    水题 给出n个数 排序后判断它们是否在10~13内 并且最小的数要为1 且至少两个数要为1 还要满足相邻两数之差小于等于2

    AC代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 typedef unsigned long long ull;
     5 
     6 namespace io {
     7     const int SIZE = 1e7 + 10;
     8     char inbuff[SIZE];
     9     char *l, *r;
    10     inline void init() {
    11         l = inbuff;
    12         r = inbuff + fread(inbuff, 1, SIZE, stdin);
    13     }
    14     inline char gc() {
    15         if (l == r) init();
    16         return (l != r) ? *(l++) : EOF;
    17     }
    18     void read(int &x) {
    19         x = 0; char ch = gc();
    20         while(!isdigit(ch)) ch = gc();
    21         while(isdigit(ch)) x = x * 10 + ch - '0', ch = gc();
    22     }
    23 } using io::read;
    24 
    25 int main(){
    26     int t;
    27     scanf("%d", &t);
    28     int n;
    29     int s[105];
    30     bool flag;
    31     while (t--){
    32         scanf("%d", &n);
    33         memset(s, 0, sizeof(s));
    34         flag = true;
    35         for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
    36         sort(s + 1, s + n + 1);
    37         if (n < 10 || n > 13) flag = false;
    38         if (s[1] != 1 || s[2] != 1) flag = false;
    39         for (int i = 3; i < n; i++){
    40             if (s[i] - s[i - 1] > 2){
    41                 flag = false;
    42                 break;
    43             }
    44         }
    45         if (flag) cout<<"Yes"<<endl;
    46         else cout<<"No"<<endl;
    47     }
    48     return 0;
    49 }
  • 相关阅读:
    jQuery之$().each和$.each的区别(转)
    js获取非行间样式--有bug,忧伤
    js之数组方法
    js之检测对象类型
    for-in枚举对象属性
    jq 处理select 下拉框
    阿里大鱼短信发送服务应用实例(PHP SDK)
    php RSA 非对称加解密实例
    JS HTML table 生成 Excel文件
    php RSA 加解密实例
  • 原文地址:https://www.cnblogs.com/Misuchii/p/10969777.html
Copyright © 2011-2022 走看看