第十一届蓝桥杯校内模拟赛

第十一届蓝桥杯校内模拟赛

感受良好,网有点卡。半小时过前八题,可能会错一点细节,总体还是很愉快。然后剩下对着第9.10题发呆半小时,然后决定偷点分交卷走人,前面几题的难度感觉比省赛要低不少,9。10依然是不会

  1. 填空题
    问题描述
      在计算机存储中,15.125GB是多少MB?
    答案提交
      这是一道结果填空的题,你只需要算出结果后提交即可。本题的结果为一个整数,在提交答案时只填写这个整数,填写多余的内容将无法得分。
15488
  1. 填空题
    问题描述
      1200000有多少个约数(只计算正约数)。
    答案提交
      这是一道结果填空的题,你只需要算出结果后提交即可。本题的结果为一个整数,在提交答案时只填写这个整数,填写多余的内容将无法得分。
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <iterator>
#include <algorithm>
using namespace std;
int main(){
    int ans = 0;
    int num = 1200000;
    for (int i = 1; i <= num; ++i) {
        if(num % i == 0)
            ans ++;
    }
    cout<<ans;
    return 0;
}

答案是96

  1. 填空题
    问题描述
      在1至2019中,有多少个数的数位中包含数字9?
      注意,有的数中的数位中包含多个9,这个数只算一次。例如,1999这个数包含数字9,在计算只是算一个数。
    答案提交
      这是一道结果填空的题,你只需要算出结果后提交即可。本题的结果为一个整数,在提交答案时只填写这个整数,填写多余的内容将无法得分。
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <iterator>
#include <algorithm>
using namespace std;
bool is_ok(int n){
    while (n){
        int mid = n % 10;
        if(mid == 9){
            return true;
        }
        n /= 10;
    }
    return false;
}

int main(){
    int ans = 0;
    int num = 2019;
    for (int i = 1; i <= num; ++i) {
        if(is_ok(i))
            ans ++;
    }
    cout<<ans;
    return 0;
}

答案是544

  1. 填空题
    问题描述
      一棵包含有2019个结点的树,最多包含多少个叶结点?
    答案提交
      这是一道结果填空的题,你只需要算出结果后提交即可。本题的结果为一个整数,在提交答案时只填写这个整数,填写多余的内容将无法得分。

答案是2018,题目上没说是二叉树,俺认为最大的就是一个根结点拖着2018个叶结点

  1. 题目描述
    问题描述
      在数列 a[1], a[2], …, a[n] 中,如果对于下标 i, j, k 满足 0<i<j<k<n+1 且 a[i]<a[j]<a[k],则称 a[i], a[j], a[k] 为一组递增三元组,a[j]为递增三元组的中心。
      给定一个数列,请问数列中有多少个元素可能是递增三元组的中心。
    输入格式
      输入的第一行包含一个整数 n。
      第二行包含 n 个整数 a[1], a[2], …, a[n],相邻的整数间用空格分隔,表示给定的数列。
    输出格式
      输出一行包含一个整数,表示答案。
    样例输入
    5
    1 2 5 3 5
    样例输出
    2
    样例说明
      a[2] 和 a[4] 可能是三元组的中心。
    评测用例规模与约定
      对于 50% 的评测用例,2 <= n <= 100,0 <= 数列中的数 <= 1000。
      对于所有评测用例,2 <= n <= 1000,0 <= 数列中的数 <= 10000。
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <iterator>
#include <algorithm>
using namespace std;
int main(){
  int n;
  int store[1005];
  cin>>n;
  for (int i = 1; i <= n; ++i) {
      cin>> store[i];
  }
  int ans = 0;
  for (int i = 2; i < n; ++i) {
      int j = i;
      while (--j >= 1 && store[j] >= store[i]);
      if(j == 0)
          continue;
      j = i;
      while (++j <= n && store[j] <= store[i]);
      if(j == n+1)
          continue;
      ans++;
  }
  cout<<ans;
  return 0;
}

这题打表的话,效率会更高点,代码如下:

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <iterator>
#include <algorithm>
using namespace std;
int main(){
    int n;
    int store[1005];
    cin>>n;
    for (int i = 1; i <= n; ++i) {
        cin>> store[i];
    }
    int ans = 0;
    int min_store[1005];
    int min_num = 0x7f7f7f7f;
    for (int i = 1; i <= n; ++i) {
        if(min_num > store[i]){
            min_num = store[i];
        }
        min_store[i] = min_num;
    }
    int max_num = 0;
    int max_store[1005];
    for (int i = n; i >= 1; --i) {
        if(max_num < store[i]){
            max_num = store[i];
        }
        max_store[i] = max_num;
    }
    for (int i = 2; i < n; ++i) {
        if(min_store[i] < store[i] && max_store[i] > store[i])
            ans++;
    }
    cout<<ans;
    return 0;
}

6.题目描述
问题描述
  小明对类似于 hello 这种单词非常感兴趣,这种单词可以正好分为四段,第一段由一个或多个辅音字母组成,第二段由一个或多个元音字母组成,第三段由一个或多个辅音字母组成,第四段由一个或多个元音字母组成。
  给定一个单词,请判断这个单词是否也是这种单词,如果是请输出yes,否则请输出no。
  元音字母包括 a, e, i, o, u,共五个,其他均为辅音字母。
输入格式
  输入一行,包含一个单词,单词中只包含小写英文字母。
输出格式
  输出答案,或者为yes,或者为no。
样例输入
lanqiao
样例输出
yes
样例输入
world
样例输出
no
评测用例规模与约定
  对于所有评测用例,单词中的字母个数不超过100。

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <iterator>
#include <algorithm>
using namespace std;
int main(){
    string input;
    cin>>input;
    map<char,bool> s_map;
    s_map['a'] = true;
    s_map['e'] = true;
    s_map['i'] = true;
    s_map['o'] = true;
    s_map['u'] = true;
    int i = 0;
    //第一段
    if(s_map[input[i]] || i >= input.length()){
        cout<<"no";
        return 0;
    } else{
        while (!s_map[input[++i]]);
    }
    //第二段
    if(!s_map[input[i]] || i >= input.length()){
        cout<<"no";
        return 0;
    } else{
        while (s_map[input[++i]]);
    }
    //第三段
    if(s_map[input[i]] || i >= input.length()){
        cout<<"no";
        return 0;
    } else{
        while (!s_map[input[++i]]);
    }
    //第四段
    if(!s_map[input[i]] || i >= input.length()){
        cout<<"no";
        return 0;
    } else{
        while (s_map[input[++i]]);
    }
    if(i == input.length())
        cout<<"yes";
    else
        cout<<"no";
    return 0;
}
  1. 题目描述
    问题描述
      一个正整数如果任何一个数位不大于右边相邻的数位,则称为一个数位递增的数,例如1135是一个数位递增的数,而1024不是一个数位递增的数。
      给定正整数 n,请问在整数 1 至 n 中有多少个数位递增的数?
    输入格式
      输入的第一行包含一个整数 n。
    输出格式
      输出一行包含一个整数,表示答案。
    样例输入
    30
    样例输出
    26
    评测用例规模与约定
      对于 40% 的评测用例,1 <= n <= 1000。
      对于 80% 的评测用例,1 <= n <= 100000。
      对于所有评测用例,1 <= n <= 1000000。
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <iterator>
#include <algorithm>
using namespace std;
bool is_ok(long long n){
    if(n < 10)
        return true;
    string mid = "";
    while (n){
        int temp = n % 10;
        mid = char('0' + temp) + mid;
        n = n/10;
    }
    if(mid.length() > 1){
        for (int i = 0; i < mid.length() -1; ++i) {
            if(mid[i] > mid[i+1])
                return false;
        }
    }
    return true;
}
int main(){
    long long  n;
    int ans = 0;
    cin>>n;
    for (int i = 1; i <= n; ++i) {
        if(is_ok(i))
            ans++;
    }
    cout<<ans;
    return 0;
}
  1. 题目描述
    问题描述
      小明有一块空地,他将这块空地划分为 n 行 m 列的小块,每行和每列的长度都为 1。
      小明选了其中的一些小块空地,种上了草,其他小块仍然保持是空地。
      这些草长得很快,每个月,草都会向外长出一些,如果一个小块种了草,则它将向自己的上、下、左、右四小块空地扩展,这四小块空地都将变为有草的小块。
      请告诉小明,k 个月后空地上哪些地方有草。
    输入格式
      输入的第一行包含两个整数 n, m。
      接下来 n 行,每行包含 m 个字母,表示初始的空地状态,字母之间没有空格。如果为小数点,表示为空地,如果字母为 g,表示种了草。
      接下来包含一个整数 k。
    输出格式
      输出 n 行,每行包含 m 个字母,表示 k 个月后空地的状态。如果为小数点,表示为空地,如果字母为 g,表示长了草。
    样例输入
    4 5
    .g…

    …g…

    2
    样例输出
    gggg.
    gggg.
    ggggg
    .ggg.
    评测用例规模与约定
      对于 30% 的评测用例,2 <= n, m <= 20。
      对于 70% 的评测用例,2 <= n, m <= 100。
      对于所有评测用例,2 <= n, m <= 1000,1 <= k <= 1000。
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <iterator>
#include <algorithm>
using namespace std;
typedef struct {
    int row;
    int col;
}ds;
int main(){
    char store[1005][1005] = {0};
    vector<ds> vec;
    int n,m,k;
    cin>>n>>m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin>>store[i][j];
            if(store[i][j] == 'g'){
                ds mid;
                mid.row = i;
                mid.col = j;
                vec.push_back(mid);
            }
        }
    }
    cin>>k;
    for (int i = 0; i < k; ++i) {
        vector<ds> vec_2;
        for (vector<ds>::iterator it = vec.begin(); it != vec.end(); it++) {
            ds mid = *it;
            //上
            if(mid.row -1 >= 0 && store[mid.row-1][mid.col] == '.'){
                store[mid.row-1][mid.col] = 'g';
                ds temp;
                temp.row = mid.row -1;
                temp.col = mid.col;
                vec_2.push_back(temp);
            }
            //下
            if(mid.row + 1 < n && store[mid.row+1][mid.col] == '.'){
                store[mid.row+1][mid.col] = 'g';
                ds temp;
                temp.row = mid.row +1;
                temp.col = mid.col;
                vec_2.push_back(temp);
            }
            //左
            if(mid.col - 1 >= 0 && store[mid.row][mid.col-1] == '.'){
                store[mid.row][mid.col-1] = 'g';
                ds temp;
                temp.row = mid.row;
                temp.col = mid.col -1;
                vec_2.push_back(temp);
            }
            //右
            if(mid.col + 1 < m && store[mid.row][mid.col+1] == '.'){
                store[mid.row][mid.col+1] = 'g';
                ds temp;
                temp.row = mid.row;
                temp.col = mid.col +1;
                vec_2.push_back(temp);
            }
        }
        for (vector<ds>::iterator it = vec_2.begin(); it != vec_2.end(); it++) {
            vec.push_back(*it);
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <m ; ++j) {
            cout<<store[i][j];
        }
        cout<<endl;
    }
    return 0;
}
  1. 题目描述
    问题描述
      小明想知道,满足以下条件的正整数序列的数量:
      1. 第一项为 n;
      2. 第二项不超过 n;
      3. 从第三项开始,每一项小于前两项的差的绝对值。
      请计算,对于给定的 n,有多少种满足条件的序列。
    输入格式
      输入一行包含一个整数 n。
    输出格式
      输出一个整数,表示答案。答案可能很大,请输出答案除以10000的余数。
    样例输入
    4
    样例输出
    7
    样例说明
      以下是满足条件的序列:
      4 1
      4 1 1
      4 1 2
      4 2
      4 2 1
      4 3
      4 4
    评测用例规模与约定
      对于 20% 的评测用例,1 <= n <= 5;
      对于 50% 的评测用例,1 <= n <= 10;
      对于 80% 的评测用例,1 <= n <= 100;
      对于所有评测用例,1 <= n <= 1000。

这题代码不保证正确性,偷分代码,能偷几分是几分

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <iterator>
#include <algorithm>
using namespace std;
int store[1005][1005];
int fun(int x,int y)
{
  if(store[x][y]!=0)
      return store[x][y];
  for(int i = abs(x-y)-1; i >= 0; i--)
  {
      store[x][y] += fun(y,i);
  }
  store[y][x] = store[x][y];
  return store[x][y];
}
int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++)
  {
      store[i][i] = 1;
      store[i][0] = 1;
      store[0][i] = 1;
  }
  for(int i = 1; i <= n; i++)
  {
      ans += fun(n,i);
      ans %= 10000;
  }
  cout << ans << endl;
  return 0;
}
  1. 题目描述
    问题描述
      小明要组织一台晚会,总共准备了 n 个节目。然后晚会的时间有限,他只能最终选择其中的 m 个节目。
      这 n 个节目是按照小明设想的顺序给定的,顺序不能改变。
      小明发现,观众对于晚上的喜欢程度与前几个节目的好看程度有非常大的关系,他希望选出的第一个节目尽可能好看,在此前提下希望第二个节目尽可能好看,依次类推。
      小明给每个节目定义了一个好看值,请你帮助小明选择出 m 个节目,满足他的要求。
    输入格式
      输入的第一行包含两个整数 n, m ,表示节目的数量和要选择的数量。
      第二行包含 n 个整数,依次为每个节目的好看值。
    输出格式
      输出一行包含 m 个整数,为选出的节目的好看值。
    样例输入
    5 3
    3 1 2 5 4
    样例输出
    3 5 4
    样例说明
      选择了第1, 4, 5个节目。
    评测用例规模与约定
      对于 30% 的评测用例,1 <= n <= 20;
      对于 60% 的评测用例,1 <= n <= 100;
      对于所有评测用例,1 <= n <= 100000,0 <= 节目的好看值 <= 100000。

这题代码不保证正确性,偷分代码,能偷几分是几分

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <iterator>
#include <algorithm>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int store[100005]={0};
  for (int i = 0; i < n; ++i) {
      cin>>store[i];
  }
  int i = 0;
  while (store[i+1] > store[i] && i <= n - m)
      i++;
  cout<<store[i];
  i++;
  for (int j = 2; j <= m; ++j) {
      while (store[i+1] > store[i] && i <= n - m + j)
          i++;
      cout<<" "<<store[i];
      i++;
  }
  return 0;
}
发布了139 篇原创文章 · 获赞 67 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_43422111/article/details/104860840