当前位置: 首页 > news >正文

OJ-0905

题目

在这里插入图片描述
示例1:

输入:
10 10 56 34 99 1 87 8 99 3 255 6 99 5 255 4 99 7 255 2 99 9 255 21
3 4
输出:
99

示例2:

输入:
10 10 255 34 0 1 255 8 0 3 255 6 0 5 255 4 0 7 255 2 0 9 255 21
3 5
输出:
255
import java.util.Scanner;public class 灰度图恢复 {public static void main(String[] args) {Scanner in = new Scanner(System.in);String[] str = in.nextLine().split(" ");int len = (str.length - 2) / 2;int[] pixel = new int[len];int[] num = new int[len];for (int i = 0; i < len; i++) {pixel[i] = Integer.parseInt(str[2 * (i + 1)]);// 2 4 6num[i] = Integer.parseInt(str[2 * (i + 1) + 1]);// 3 5 7}int x = in.nextInt();int y = in.nextInt();int count = x * Integer.parseInt(str[0]) + y;int index = 0;while (index < len) {count -= num[index];if (count < 0) {break;}index++;}System.out.println(pixel[index]);}
}

https://blog.csdn.net/weixin_52908342/article/details/135590957


http://www.mrgr.cn/news/20641.html

相关文章:

  • 机器学习算法:监督学习中的线性回归
  • c++ 创建对象 和 使用对象
  • 微信小程序仿微信聊天界面
  • C++设计模式——Command命令模式
  • pico手柄和人物模型手部旋转同步,实现手柄控制手臂手部位置移动、手部旋转和手指的操作了
  • 2024 年高教社杯全国大学生数学建模竞赛B题4小问解题思路(第二版)
  • python circular import python循环导入问题
  • 进销存管理系统源码
  • C++ 模板进阶知识——万能引用
  • blast的快速安装使用-简易版
  • 基于STM32的RTOS--freertos的使用(HAL实现多任务)
  • 逻辑回归模型
  • vue3 通过 绑定 ref 重置 DOM
  • 【计算机网络】TCP连接如何确保传输的可靠性
  • PMP错题总结(十七)
  • Circuitjs 在线电路模拟器使用指南
  • linux curl命令介绍以及使用
  • 科研绘图系列:R语言折线图(linechart plots)
  • 2024年高教杯国赛(E题)数学建模竞赛解题思路|完整代码论文集合
  • Mybatis 多表联查