您的位置:首页 > 健康 > 美食 > 电商网站开发文档_聚名网合法吗_杭州新站整站seo_成人再就业培训班

电商网站开发文档_聚名网合法吗_杭州新站整站seo_成人再就业培训班

2025/4/19 10:47:13 来源:https://blog.csdn.net/shaozheng0503/article/details/147100241  浏览:    关键词:电商网站开发文档_聚名网合法吗_杭州新站整站seo_成人再就业培训班
电商网站开发文档_聚名网合法吗_杭州新站整站seo_成人再就业培训班

前言


本文总结了六个编程题目的解题思路与核心考点,涵盖基础语法、逻辑分析、贪心算法、数学推导等知识点。每个题目均从问题本质出发,通过巧妙的算法设计或数学优化降低复杂度,展现了不同场景下的编程思维与解题技巧。以下为各题的详细考点解析。


题目考点总结

  1. 胜利终将属于你
    • 考点:基础输出语句
    • 关键点:直接输出固定字符串,无需任何计算或逻辑处理,考察对编程语言基本语法的掌握。
  1. 团队赛
    • 考点:条件判断与逻辑分析
    • 关键点:通过严格比较三人能力值,判断是否存在队长。需注意条件覆盖的完整性(逐一检查每个成员是否满足队长条件)。
  1. 破译密码
    • 考点:贪心算法与任务调度(Johnson 法则)
    • 关键点:将任务分为两组,分别按破译时间升序和传输时间降序排序,合并后模拟处理流程以最小化总完成时间。
  1. 浓缩咖啡液
    • 考点:极值判断与数学性质
    • 关键点:混合后的浓度必在初始浓度的最小值和最大值之间,只需判断目标浓度是否在此区间内。
  1. 蓝桥运算
    • 考点:数学推导与优化计算
    • 关键点:分析区间操作对总和的贡献,避免逐个元素遍历。通过计算操作对数与奇偶性快速更新总和。
  1. 插入数字
    • 考点:字符串操作与去重处理
    • 关键点:枚举所有插入位置和数字,利用集合去重,同时处理前导零问题(首位不能插入 0)。

通过以上题目,可全面锻炼基础编程能力、算法设计思维及数学建模技巧,尤其注重对问题本质的洞察与高效实现。

完整Java代码

1. 胜利终将属于你

public class Main {public static void main(String[] args) {System.out.println("I will fight and win");}
}

2. 团队赛

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int a = scanner.nextInt();int b = scanner.nextInt();int c = scanner.nextInt();if (a > b + c) {System.out.println("l");} else if (b > a + c) {System.out.println("q");} else if (c > a + b) {System.out.println("b");} else {System.out.println(-1);}}
}

3. 破译密码

import java.util.*;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int n = scanner.nextInt();int[] A = new int[n];int[] B = new int[n];for (int i = 0; i < n; i++) A[i] = scanner.nextInt();for (int i = 0; i < n; i++) B[i] = scanner.nextInt();List<Task> groupA = new ArrayList<>();List<Task> groupB = new ArrayList<>();// 分组:A_i <= B_i的为组A,其余为组Bfor (int i = 0; i < n; i++) {if (A[i] <= B[i]) {groupA.add(new Task(A[i], B[i]));} else {groupB.add(new Task(A[i], B[i]));}}// 组A按破译时间升序,组B按传输时间降序Collections.sort(groupA, Comparator.comparingInt(t -> t.a));Collections.sort(groupB, (t1, t2) -> t2.b - t1.b);// 合并两组List<Task> merged = new ArrayList<>();merged.addAll(groupA);merged.addAll(groupB);// 计算总时间int currentTime = 0;int transmitEnd = 0;for (Task task : merged) {currentTime += task.a; // 破译时间累加int start = Math.max(currentTime, transmitEnd); // 传输开始时间取最大值transmitEnd = start + task.b; // 更新传输结束时间}System.out.println(Math.max(currentTime, transmitEnd));}static class Task {int a, b;Task(int a, int b) {this.a = a;this.b = b;}}
}

4. 浓缩咖啡液

import java.util.*;public class CoffeeConcentration {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int T = scanner.nextInt();while (T-- > 0) {int n = scanner.nextInt();int m = scanner.nextInt();int[] A = new int[n];for (int i = 0; i < n; i++) A[i] = scanner.nextInt();Arrays.sort(A);// 目标浓度在最小和最大之间即可System.out.println(A[0] <= m && m <= A[n - 1] ? "YES" : "NO");}}
}

5. 蓝桥运算

import java.util.Scanner;public class LanqiaoOperation {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int n = scanner.nextInt();int q = scanner.nextInt();long sum = 0;// 初始数组和for (int i = 0; i < n; i++) sum += scanner.nextInt();// 处理每次操作while (q-- > 0) {int L = scanner.nextInt();int R = scanner.nextInt();int len = R - L + 1;int pairs = len / 2;sum -= pairs; // 每对贡献-1if (len % 2 == 1) sum += R; // 奇数长度的最后一个元素贡献+R}System.out.println(sum);}
}

6. 插入数字

import java.util.*;public class InsertNumber {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);String n = scanner.next();Set<String> set = new HashSet<>();for (int i = 0; i <= n.length(); i++) {char start = (i == 0) ? '1' : '0'; // 开头不能为0for (char c = start; c <= '9'; c++) {String newNum = n.substring(0, i) + c + n.substring(i);set.add(newNum);}}System.out.println(set.size()); // 自动去重后的数量}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com