第十一届蓝桥杯大赛第二场省赛试题

门牌制作

在这里插入图片描述

import java.io.IOException;
class MC {
    public void run() throws IOException {
        int cnt = 0;
        for (int i = 1; i <= 2020; i++) {
            int x = i, t = 0;
            while (x > 0){
                if (x % 10 == 2) t++;
                x /= 10;
            }
            cnt += t;
        }
        System.out.println(cnt);
    }
}
public class Main {
    public static void main(String[] args) throws IOException {
        new MC().run();
    }
}

寻找2020

在这里插入图片描述
16520

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

class MC {
    int N = 310;
    int n = 300;
    int[][] a = new int[N][N];

    //300x300
    public void run() throws IOException {
        for (int i = 1; i <= n; i++) {
            String s = br.readLine();
            for (int j = 1; j <= n; j++) {
                a[i][j] = s.charAt(j - 1) - '0';
            }
        }
        int cnt = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                //左右
                if (j + 3 <= n && a[i][j] == 2 && a[i][j + 1] == 0 && a[i][j + 2] == 2 && a[i][j + 3] == 0 ) cnt ++;
                //上下
                if (i + 3 <= n && a[i][j] == 2 && a[i + 1][j] == 0 && a[i  +2][j] == 2 && a[i + 3][j] == 0 ) cnt ++;
                //左上右下
                if (i + 3 <= n && j + 3 <= n && a[i][j] == 2 && a[i + 1][j + 1] == 0 && a[i  +2][j + 2] == 2 && a[i + 3][j  +3] == 0 ) cnt++;
            }
        }
        System.out.println(cnt);
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
}
public class Main {
    public static void main(String[] args) throws IOException {
        new MC().run();
    }
}

蛇形填数

在这里插入图片描述

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class MC {
    int[][] a = new int[200][200];
    int n = 70;
    public void run() throws IOException {
        int cnt = 1;
        boolean f = false;
        int x = 1, y = 1;
        a[x][y] = cnt;
        for (int i = 2; i <= n; i++) {
            if (!f){
                f = true;
                y += 1;
                cnt += 1;
                a[x][y] = cnt;
                for (int j = 1; j < i; j++) {
                    x += 1;
                    y -= 1;
                    cnt++;
                    a[x][y] = cnt;
                }
            }else {
                f = false;
                x += 1;
                cnt += 1;
                a[x][y] = cnt;
                for (int j = 1; j < i; j++) {
                    x -= 1;
                    y += 1;
                    cnt++;
                    a[x][y] = cnt;
                }
            }
        }
        System.out.println(a[20][20]);
    }
}
public class Main {
    public static void main(String[] args) throws IOException {
        new MC().run();
    }
}

七段码

在这里插入图片描述

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

class MC {
    int N = 10;
    int[] a = new int[N];
    boolean[] st = new boolean[N];
    int k1 = 7, k2 = 2;

    int res = 0;

    void build(int t, int[][] g){
        switch (t){
            case 1:
                g[1][1] = 1;
                g[1][2] = 1;
                g[1][3] = 1;
                break;
            case 2:
                g[3][3] = 1;
                g[2][3] = 1;
                break;
            case 3:
                g[3][3] = 1;
                g[4][3] = 1;
                g[5][3] = 1;
                break;
            case 4:
                g[5][2] = 1;
                break;
            case 5:
                g[3][1] = 1;
                g[4][1] = 1;
                g[5][1] = 1;
                break;
            case 6:
                g[2][1] = 1;
                break;
            case 7:
                g[3][2] = 1;
                g[3][1] = 1;
                g[3][3] = 1;
                break;
            default:
                break;
        }
    }

    void dfs2(int x, int y, int px, int py, int[][] g){
        if (x == px && y == py) return;
        if (x < 1 || x > 5 || y < 1 || y > 3) return;
        if (g[x][y] == 0) return;
        g[x][y] = 0;
        dfs2(x - 1, y, x, y, g);
        dfs2(x + 1, y, x, y, g);
        dfs2(x , y - 1, x, y, g);
        dfs2(x , y + 1, x, y, g);
    }

    void check() {
        int[][] g = new int[6][4];
        for (int i = 1; i <= k2; i++) {
            build(a[i], g);
        }
        //联通性检查
        int t = 0;
        for (int i = 1; i <= 5; i++) {
            for (int j = 1; j <= 3; j++) {
                if (g[i][j] == 1){
                    dfs2(i, j, 0, 0, g);
                    t++;
                }
            }
        }
        if (t == 1) {
            res++;
        }
    }

    void dfs(int cnt) {
        if (cnt == k2 + 1){
            check();
            return;
        }
        for (int i = 1; i <= k1; i++) {
            if (st[i] ||  i < a[cnt - 1]) continue;
            st[i] = true;
            a[cnt] = i;
            dfs(cnt + 1);
            st[i] = false;
        }
    }

    public void run(){
        for (int i = 1; i <= 7; i++) {
            k2 = i;
            dfs(1);
        }
        System.out.println(res);
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
}

public class Main {
    public static void main(String[] args) {
        new MC().run();
    }
}

排序

在这里插入图片描述

跟着大佬走

成绩分析

在这里插入图片描述

import java.io.IOException;
import java.util.Scanner;

class MC {

    int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
    int sum = 0;
    public void run() throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            int x = sc.nextInt();
            sum += x;
            min = Math.min(min, x);
            max = Math.max(max, x);
        }
        System.out.println(max);
        System.out.println(min);
        double avg = (double) sum / n;
        System.out.printf("%.2f", avg);
    }

}

public class Main {
    public static void main(String[] args) throws IOException {
        new MC().run();
    }
}

单词分析

在这里插入图片描述

import java.io.IOException;
import java.util.Scanner;
class MC {
    int[] cnt = new int['z' + 1];
    public void run() throws IOException {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        for (int i = 0; i < s.length(); i++) {
            cnt[s.charAt(i)] ++;
        }
        char c = 0;
        int max = Integer.MIN_VALUE;
        for (int i = 'a'; i <= 'z'; i++) {
            if (cnt[i] > max){
                max = cnt[i];
                c = (char) i;
            }else if (cnt[i] == max){
                if ((char)i < c) c = (char) i;
            }
        }
        System.out.println(c);
        System.out.println(max);
    }

}
public class Main {
    public static void main(String[] args) throws IOException {
        new MC().run();
    }
}

数字三角形

在这里插入图片描述
在这里插入图片描述
跟着大佬走

import java.io.IOException;
import java.util.Scanner;
class MC {
    int N = 110;
    int[][] g = new int[N][N], f = new int[N][N];
    public void run() throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                g[i][j] = sc.nextInt();
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                //为什么可以取最大值?例如现在是倒数第1层,该层的最大值取决于倒数第2层,倒数第二层的最大值取决于倒数第3层,如此类推
                f[i][j] = Math.max(f[i - 1][j], f[i - 1][j - 1]) + g[i][j];
            }
        }
        //从往左往右的次数差值小于等于1可知,往左往右的次数是几乎相等的且差值不超过1,说明答案在最后一层的中间位置
        int res = f[n][n / 2 + 1];
        if (n % 2 == 0) res = Math.max(res, f[n][n / 2]);
        System.out.println(res);

    }
}
public class Main {
    public static void main(String[] args) throws IOException {
        new MC().run();
    }
}

子串分值和

在这里插入图片描述

跟着大佬走

import java.io.IOException;
import java.util.Scanner;
class MC {
    int N = (int) (1e5 + 10);
    //记录每个字符最后出现的位置
    int[] pos = new int[26];
    int[] f = new int[N];
    public void run(){
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int n = str.length();
        str = " " + str;
        long ans = 0;
        //遍历每个字符
        for (int i = 1; i <= n; i++) {
            int t = str.charAt(i) - 'a';
            //1代表str[i]自身这一个字符,一定会多出这种可能
            //i之前有i-1个子串,加上这个str[i]最多能产生i-1种可能
            f[i] = f[i - 1] + 1 + i - 1 - pos[t];
            pos[t] = i;
            ans += f[i];
        }
        System.out.println(ans);
    }
}
public class Main {
    public static void main(String[] args) throws IOException {
        new MC().run();
    }
}

装饰珠

跟着大佬走

内容概要:本文档详细介绍了在三台CentOS 7服务器(IP地址分别为192.168.0.157、192.168.0.158和192.168.0.159)上安装和配置Hadoop、Flink及其他大数据组件(如Hive、MySQL、Sqoop、Kafka、Zookeeper、HBase、Spark、Scala)的具体步骤。首先,文档说明了环境准备,包括配置主机名映射、SSH免密登录、JDK安装等。接着,详细描述了Hadoop集群的安装配置,包括SSH免密登录、JDK配置、Hadoop环境变量设置、HDFS和YARN配置文件修改、集群启动与测试。随后,依次介绍了MySQL、Hive、Sqoop、Kafka、Zookeeper、HBase、Spark、Scala和Flink的安装配置过程,包括解压、环境变量配置、配置文件修改、服务启动等关键步骤。最后,文档提供了每个组件的基本测试方法,确保安装成功。 适合人群:具备一定Linux基础和大数据组件基础知识的运维人员、大数据开发工程师以及系统管理员。 使用场景及目标:①为大数据平台建提供详细的安装指南,确保各组件能够顺利安装和配置;②帮助技术人员快速掌握Hadoop、Flink等大数据组件的安装与配置,提升工作效率;③适用于企业级大数据平台的建与维护,确保集群稳定运行。 其他说明:本文档不仅提供了详细的安装步骤,还涵盖了常见的配置项解释和故障排查建议。建议读者在安装过程中仔细阅读每一步骤,并根据实际情况调整配置参数。此外,文档中的命令和配置文件路径均为示例,实际操作时需根据具体环境进行适当修改。
在无线通信领域,天线阵列设计对于信号传播方向和覆盖范围的优化至关重要。本题要求设计一个广播电台的天线布局,形成特定的水平面波瓣图,即在东北方向实现最大辐射强度,在正东到正北的90°范围内辐射衰减最小且无零点;而在其余270°范围内允许出现零点,且正西和西南方向必须为零。为此,设计了一个由4个铅垂铁塔组成的阵列,各铁塔上的电流幅度相等,相位关系可自由调整,几何布置和间距不受限制。设计过程如下: 第一步:构建初级波瓣图 选取南北方向上的两个点源,间距为0.2λ(λ为电磁波波长),形成一个端射阵。通过调整相位差,使正南方向的辐射为零,计算得到初始相位差δ=252°。为了满足西南方向零辐射的要求,整体相位再偏移45°,得到初级波瓣图的表达式为E1=cos(36°cos(φ+45°)+126°)。 第二步:构建次级波瓣图 再选取一个点源位于正北方向,另一个点源位于西南方向,间距为0.4λ。调整相位差使西南方向的辐射为零,计算得到相位差δ=280°。同样整体偏移45°,得到次级波瓣图的表达式为E2=cos(72°cos(φ+45°)+140°)。 最终组合: 将初级波瓣图E1和次级波瓣图E2相乘,得到总阵的波瓣图E=E1×E2=cos(36°cos(φ+45°)+126°)×cos(72°cos(φ+45°)+140°)。通过编程实现计算并绘制波瓣图,可以看到三个阶段的波瓣图分别对应初级波瓣、次级波瓣和总波瓣,最终得到满足广播电台需求的总波瓣图。实验代码使用MATLAB编写,利用polar函数在极坐标下绘制波瓣图,并通过subplot分块显示不同阶段的波瓣图。这种设计方法体现了天线阵列设计的基本原理,即通过调整天线间的相对位置和相位关系,控制电磁波的辐射方向和强度,以满足特定的覆盖需求。这种设计在雷达、卫星通信和移动通信基站等无线通信系统中得到了广泛应用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值