P1046题目要求

P1046题目链接

P1046题解

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int counter = 0;int[] array = new int[10];for (int i = 0; i < 10; i++) {array[i] = scanner.nextInt();}int height = scanner.nextInt() + 30;for (int i = 0; i < 10; i++) {if (array[i] <= height) {counter++;}}System.out.println(counter);scanner.close();}
}

P1047题目要求

P1047题目链接

P1047题解

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int length = scanner.nextInt();int lineNum = scanner.nextInt();int counter = 0;//注意树维L+1棵int[] array = new int[length+1];for (int i = 0; i < lineNum; i++) {int from = scanner.nextInt(), to = scanner.nextInt();for (int j = from; j <= to; j++) {array[j] = 1;}}for (int i = 0; i <= length; i++) {if (array[i] == 0) {counter++;}}System.out.println(counter);scanner.close();}
}

P1427题目要求

P1427题目链接

P1427题解

以前写的,竟然还用了ArrayList……

import java.util.ArrayList;
import java.util.Scanner;public class Main {public static void main(String[] args) {ArrayList<Integer> array = new ArrayList<>();Scanner scan = new Scanner(System.in);while(scan.hasNext()) {int x = scan.nextInt();if (x != 0) {array.add(x);} else {break;}}int length = array.size();for (int i = length-1; i >= 0; i--) {System.out.print(array.get(i) + " ");}scan.close();}}

P1428题目要求

P1428题目链接

P1428题解

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scan = new Scanner(System.in);int n = scan.nextInt();int[] array = new int[n];int[] result = new int[n];int m;int count;for (int i = 0; i < n; i++) {m = scan.nextInt();array [i] = m;count = 0;for (int j = i; j>=0; j--) {if (array [i] > array [j]) {count++;}}result[i] = count;}for (int i : result) {System.out.print(i + " ");}scan.close();}}

P2141题目要求

P2141题目链接


P2141题解

这题小麻烦一些,解题历程

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int num = scanner.nextInt();int[] array = new int[num];for (int i = 0; i < num; i++) {array[i] = scanner.nextInt();}int[] counterArr = new int[num];for (int i = 0; i < num; i++) {int now = array[i];for (int j = 0; j < num; j++) {if (j == i) {continue;}int num1 = array[j];for (int k = 0; k < num; k++) {if (k == i || k == j) {continue;}int num2 = array[k];if (num1 + num2 == now) {counterArr[i] = 1;break;}}}}int counter = 0;for (int i = 0; i < num; i++) {if (counterArr[i] == 1) {counter++;}}System.out.println(counter);scanner.close();}
}

P1567题目要求

P1567题目链接

P1567题解

这个题太难了,性能卡的太死了,1s+125MB的双限制在本题中,对Java用户来说太难了!!!!!!强烈谴责!!!
辛酸的解题历程

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;public class Main {public static void main(String[] args) throws IOException {BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));int num = reader.read();reader.readLine();String[] arr = reader.readLine().split(" ");int counter = 0;int max = 0;for (int i = 1; i < arr.length; i++) {int tem1 = Integer.parseInt(arr[i]);int tem2 = Integer.parseInt(arr[i-1]);if((tem1 - tem2) > 0) {counter++;} else {max=Math.max(max, counter);counter = 0;}}System.out.println(max+1);}
}

洛谷入门题P1046、P1047、P1427、P1428、P2141、P1567题解(Java语言描述)相关推荐

  1. 洛谷入门题单 --【入门1】顺序结构 题解

    - [P1001 A+B Problem] - [P1000 超级玛丽游戏] - [P5703 [深基2.例5]苹果采购] - [P5704 [深基2.例6]字母转换] - [P5705 [深基2.例 ...

  2. Java P1035 [NOIP2002 普及组] 级数求和 洛谷入门题

    P1035 [NOIP2002 普及组] 级数求和 题目描述 已知:Sn=1+1/2+1/3+-+1/nS_n= 1+1/2+1/3+-+1/nSn​=1+1/2+1/3+-+1/n.显然对于任意一个 ...

  3. 洛谷入门题P1008、P1035、P1423、P1424、P1980题解(Java语言描述)

    P1008题目描述 P1008题目链接 P1008题解 public class Main {private static byte[] arr = new byte[9];public static ...

  4. 洛谷入门题P1422、P1085、P1089、P1909题解(Java语言描述)

    P1422题目描述 P1422题目链接 P1422题解 import java.util.Scanner;public class Main {public static void main(Stri ...

  5. 洛谷入门题P1000、P1001、P1421、P1425题解(Java语言描述)

    P1000题目要求 P1000题目链接 P1000题解 public class Main {public static void main(String[] args) {System.out.pr ...

  6. 洛谷--入门题 (1)

    1.上学迟到 代码:(转) #include<cstdio> #include<cmath>using namespace std; int s, v;int main() { ...

  7. 洛谷oj题单【入门2】分支结构-入门难度(Java)

    洛谷oj题单[入门2]分支结构-入门难度(Java) 来源:https://www.luogu.com.cn/training/101#problems P5709 [深基2.习6]Apples Pr ...

  8. 洛谷刷题记录(入门第一题)

    大家好,先自我介绍一下.我是sjksndnfkwks,目前大一学生,数据科学学院,从今天也就是2022年12月26日开始记录自己洛谷刷题的过程.目前为止我接触过java.python两种编程语言,所以 ...

  9. 洛谷刷题C语言:切蛋糕、概率、Bridž、NOTE、DOMINO

    记录洛谷刷题C语言qaq [NOI Online 2021 入门组] 切蛋糕 题目描述 Alice.Bob 和 Cindy 三个好朋友得到了一个圆形蛋糕,他们打算分享这个蛋糕. 三个人的需求量分别为 ...

最新文章

  1. oralce中级OCP考试时间和题量以及通过率
  2. jQuery--.css(width)和.width()的区别
  3. 学习CSS(页面布局篇)
  4. 计算机与交通工程论文,交通工程论文.doc
  5. Error - Found cycle in the ListNode
  6. 《Python编程从入门到实践》记录之类存储在模块及其导入
  7. 自动完成代码,提高工作效率
  8. Linux基础(7)--串口编程
  9. 洛谷P3152 正整数序列
  10. openssl pkeyutl执行SM2椭圆曲线数字签名
  11. Python3学习笔记18-访问限制
  12. You-Get—— 基于 Python3 的媒体下载工具
  13. 学习继电器的工作原理及作用
  14. 理性看待 数据分析师 Hot!
  15. 一卡难求,什么时候才能买到原价显卡?
  16. html中两个日期相减,在Excel中如何让两个时间相减?
  17. 微信开发网页授权认证
  18. ORACLE存储过程中打印所有表数据的方法
  19. 帮人维护服务器犯法吗,私人做云服务器犯法吗
  20. Windows 罕见技巧全集1

热门文章

  1. 20160205.CCPP体系详解(0015天)
  2. HDU 2242 考研路茫茫——空调教室
  3. 绝对定位relative、相对定位absolute(脱离文档流)
  4. TCP close_wait内幕
  5. python字典导入mongodb_python连接mongoDB进行数据提取→常用操作指南
  6. php网站开发项目实战,PHP动态网站开发项目实战
  7. linux系统终端more,一篇文章让你学透Linux系统中的more命令
  8. vue的视图化创建项目_vue-cli3用图形化的方式创建项目
  9. Golang——文件创建和写入、OpenFile追加写入、Open读取文件、ReadBytes缓冲区读取、os.Args、flag
  10. java库里_java8之StringJoiner。终于有像guava类库里的功能了