Hadoop 概述(二)
shell定时上传linux日志信息到hdfs
从标题可以分析出来,我们要使用到shell,还要推送日志信息到hdfs上。
- 定义出上传的路径和临时路径,并配置好上传的log日志信息。
这里我使用了上一节配置的nginx的error.log
#上传log日志文件的存放路径
/bigdata/logs/upload/log/
#上传log日志文件的临时路径
/bigdata/logs/upload/templog/
将nginx的error.log放在上传log日志的文件夹下边,如下图所示
- 在~/bin目录下创建我们的shell脚本文件
vi uploadFileToHdfs.sh
##复制如下内容,并保存退出
#!/bin/bash
#set java env
export JAVA_HOME=/bigdata/install/jdk1.8.0_141
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
#set hadoop env
export HADOOP_HOME=/bigdata/install/hadoop-3.1.4
export PATH=${HADOOP_HOME}/bin:${HADOOP_HOME}/sbin:$PATH
#日志文件存放的目录
log_src_dir=/bigdata/logs/upload/log/
#待上传文件存放的目录
log_toupload_dir=/bigdata/logs/upload/templog/
#日志文件上传到hdfs的根路径
date1=`date -d last-day +%Y_%m_%d`
hdfs_root_dir=/data/log/$date1/
#打印环境变量信息
echo "envs: hadoop_home: $HADOOP_HOME"
#读取日志文件的目录,判断是否有需要上传的文件
echo "log_src_dir:"$log_src_dir
ls $log_src_dir | while read fileName
do
if [[ "$fileName" == *.log ]]; then
date=`date +%Y_%m_%d_%H_%M_%S`
#打印信息
echo "moving $log_src_dir$fileName to $log_toupload_dir"temp_$fileName"$date"
mv $log_src_dir$fileName $log_toupload_dir"temp_$fileName"$date
#将待上传的文件path写入一个列表文件will
echo $log_toupload_dir"temp_$fileName"$date >> $log_toupload_dir"will."$date
fi
done
#找到列表文件will
ls $log_toupload_dir | grep will |grep -v "_DOING_" | grep -v "_DONE_" | while read line
do
#打印信息
echo "toupload is in file:"$line
#将待上传文件列表will改名为will_DOING_
mv $log_toupload_dir$line $log_toupload_dir$line"_DOING_"
#读列表文件will_DOING_的内容(一个一个的待上传文件名) ,此处的line 就是列表中的一个待上传文件的path
cat $log_toupload_dir$line"_DOING_" |while read line
do
#打印信息
echo "puting...$line to hdfs path.....$hdfs_root_dir"
hadoop fs -mkdir -p $hdfs_root_dir
hadoop fs -put $line $hdfs_root_dir
done
mv $log_toupload_dir$line"_DOING_" $log_toupload_dir$line"_DONE_"
done
- 执行脚本,查看结果
sh uploadFileToHdfs.sh
yarn核心配置参数说明
yarn作为hadoop的资源分配和调度的基础组件,有哪些相关的参数是和这个组件有关呢?
- ResourceManager相关
yarn.resourcemanager.scheduler.class #配置调度器,apache yarn默认容量调度器,CDH默认公平调度器
yarn.resourcemanager.scheduler.client.thread-count # ResourceManager处理调度器请求的现场数量,默认50
- NodeManager相关
yarn.nodemanager.resource.detect-hardware-capabilities #是否让yarn自己检测硬件进行配置,默认false
yarn.nodemanager.resource.count-logical-processor-as-cores #是否将虚拟核数当作CPU核数,默认false
yarn.nodemanager.resource.pcores-vcores-multiplier #虚拟核数和物理核数乘数,默认为1.0
yarn.nodemanager.resource.memory-mb # NodeManager使用内存,默认8G
yarn.nodemanager.resource.system-reserved-memory-mb #NodeManager为系统保留多少内存,以上二个参数配置一个即可
yarn.nodemanager.resource.cpu-vcores #NodeManager使用CPU核数,默认8个
yarn.nodemanager.pmem-check-enabled #是否开启物流内存检查限制container,默认打开
yarn.nodemanager.vmem-check-enabled #是否开启虚拟内存检查限制container,默认代开
yarn.nodemanager.vmem-pmem-ratio #虚拟内存物理内存比例,默认2.1
- Container相关
yarn.scheduler.minimum-allocation-mb #容器最小内存,默认1G
yarn.scheduler.maximum-allocation-mb #容器最大内存,默认8G
yarn.scheduler.minimum-allocation-vcores #容器最小CPU核数,默认1个
yarn.scheduler.maximum-allocation-vcores #容器最大CPU核数,默认4个
那在部署环境我们要怎么分配呢?
eg:3台服务器,每台配置4G内存,4核CPU,4线程,如果我们处理的是1G的文件进行数据的count统计,
那么就会有 1G/128M=8个MapTask 1个ReduceTask,1个MrAppMaster,平均下来就是每个节点有3个任务,
那我们按4 3 3 的比例分配10个任务。
那我们就按照上边的参数进行配置下我们的yarn-site.xml文件
<configuration>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>hadoop01</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<!-- 如果vmem、pmem资源不够,会报错,此处将资源监察置为false -->
<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
</property>
<property>
<name>yarn.nodemanager.pmem-check-enabled</name>
<value>false</value>
</property>
<!-- 选择调度器。默认容量-->
<property>
<name>yarn.resourcemanager.scheduler.class</name>
<value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler</value>
</property>
<!--ResourceManager处理调度器请求的现场数量,一共3*4=12,留出几个供其他使用-->
<property>
<name>yarn.resourcemanager.scheduler.client.thread-count</name>
<value>8</value>
</property>
<!--是否让yarn自动检测硬件进行配置-->
<property>
<name>yarn.nodemanager.resource.detect-hardware-capabilities</name>
<value>false</value>
</property>
<!--是否将虚拟核数当作CPU核数 默认false-->
<property>
<name>yarn.nodemanager.resource.count-logical-processors-as-cores</name>
<value>false</value>
</property>
<!--虚拟核数和物理核数乘数-->
<property>
<name>yarn.nodemanager.resource.pcores-vcores-multiplier</name>
<value>1.0</value>
</property>
<!--nodemanager使用内存数,默认8g,但是服务器只有4G,修改为4g-->
<property>
<name>yarn.nodemanager.resource.memory-mb</name>
<value>4096</value>
</property>
<!--nodemanager的CPU核数,默认设置为8个,但是服务器只有4核,修改为4个-->
<property>
<name>yarn.nodemanager.resource.cpu-vcores</name>
<value>4</value>
</property>
<!--容器最小内存,默认1g-->
<property>
<name>yarn.scheduler.minimum-allocation-mb</name>
<value>1024</value>
</property>
<!--容器最大内存,默认8g,但是服务器只有4G,修改为2g-->
<property>
<name>yarn.scheduler.maximum-allocation-mb</name>
<value>2048</value>
</property>
<!--容器最小CPU核数,默认1个-->
<property>
<name>yarn.scheduler.minimum-allocation-vcores</name>
<value>1</value>
</property>
<!--容器最大CPU核数,默认4个,但是服务器只有4核,修改为2个-->
<property>
<name>yarn.schedluler.maximum-allocation-vcores</name>
<value>2</value>
</property>
<!--虚拟内存和物理内存设置比例,默认2.1-->
<property>
<name>yarn.nodemanager.vmem-pmem-ratio</name>
<value>2.1</value>
</property>
</configuration>
按上边的配置修改,我们会得到最后更加符合我们服务器硬件参数的yarn资源集群。
yarn自定义scheduler队列
yarn支持3种调度器,FIFO,容量,公平调度器。
FIFO调度算法
只有一个队列,任务执行是按照先进先出的顺序执行,无法支持多用户并发的场景。如下图
容器调度算法
yahoo开发的多用户调度器(apache yarn中默认使用)
- 特征
- 多队列:每个队列可配置一定的资源量,每个队列采用FIFO调度策略
- 容器保证:管理员可为每个队列设置资源最低保证和资源使用上限
- 灵活性:如果一个队列中的资源有剩余,可以暂时共享给需要资源的队列,而一旦该队列有新的应用程序提交,则其他队列借调的资源会归还给该队列。
- 多租户:支持多用户共享集群和多应用程序同时运行,为了防止同一个用户的作业独占队列中的资源,该调度器会对同一用户提交的作业所占资源量进行限定。
- 资源分配算法
- 队列资源分配
从root开始,使用深度优先算法,优先选择资源暂用率低的队列分配资源 - 作业资源分配
默认按照提交作业的优先级和提交时间按顺序分配资源 - 容器资源分配
按照容器的优先级分配资源
如果优先级相同,按照数据本地性原则
a. 任务和数据在同一节点
b. 任务和数据在同一机架
c. 任务和数据不在同一个节点也不在同一机架
公平调度器
- 特点
- 多队列:支持多队列多作业
- 容量保证:管理员可为每个队列设置资源最低保证和资源使用上限
- 灵活性:如果一个队列中的资源有剩余,可以暂时共享给那些需要资源的队列,而一旦该队列有新的应用程序提交,则其他队列借调的资源会归还给该队列
- 多租户:支持多用户共享集群和多应用程序同时运行,为了防止同一个用户的作业独占队列中的资源,该调度器会对同一个用户提交的作业所占资源量进行限定
- 公平调度器队列资源分配方式
FIFO策略
公平调度器每个队列资源分配策略如果是FIFO,此时就是相当于容量调度器Fair策略
Fair策略是一种基于最大最小公平算法实现的资源多路复用方式,默认情况下,每个队列内部采用该方式分配资源,同队列所有任务共享资源,在时间尺度上获得公平的资源。意味着,如果一个队列中有两个应用程序同时运行则每个应用程序可得到1/2的资源,如果是三个同时运行,则每个可以得到1/3资源
- 公平调度器和容量调度器不同点
- 核心调度策略不同
容量调度器:优先选择资源利用率的队列
公平调度器:优先选择对资源的缺额比例大的 - 每个队列可以单独设置资源分配方式
容量调度器:FIFO,DRF
公平调度器:FIFO,AIR,DRF
那我们配置一个容量调度器的队列hive,我们只需要修改capacity-scheduler.xml就可以,具体配置如下:
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. See accompanying LICENSE file.
-->
<configuration>
<property>
<name>yarn.scheduler.capacity.maximum-applications</name>
<value>10000</value>
<description>
Maximum number of applications that can be pending and running.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.maximum-am-resource-percent</name>
<value>0.1</value>
<description>
Maximum percent of resources in the cluster which can be used to run
application masters i.e. controls number of concurrent running
applications.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.resource-calculator</name>
<value>org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator</value>
<description>
The ResourceCalculator implementation to be used to compare
Resources in the scheduler.
The default i.e. DefaultResourceCalculator only uses Memory while
DominantResourceCalculator uses dominant-resource to compare
multi-dimensional resources such as Memory, CPU etc.
</description>
</property>
<!--配置root下的队列,hive和default-->
<property>
<name>yarn.scheduler.capacity.root.queues</name>
<value>default,hive</value>
<description>
The queues at the this level (root is the root queue).
</description>
</property>
<!--default 占总资源40%-->
<property>
<name>yarn.scheduler.capacity.root.default.capacity</name>
<value>40</value>
<description>Default queue target capacity.</description>
</property>
<!--hive 占总资源60%-->
<property>
<name>yarn.scheduler.capacity.root.hive.capacity</name>
<value>60</value>
<description>Default queue target capacity.</description>
</property>
<!--default 最大可以使用的队列容量-->
<property>
<name>yarn.scheduler.capacity.root.default.user-limit-factor</name>
<value>1</value>
<description>
Default queue user limit a percentage from 0.0 to 1.0.
</description>
</property>
<!--hive 最大可以使用的队列容量-->
<property>
<name>yarn.scheduler.capacity.root.hive.user-limit-factor</name>
<value>1</value>
<description>
Default queue user limit a percentage from 0.0 to 1.0.
</description>
</property>
<!--default 最大资源容量占总资源60%-->
<property>
<name>yarn.scheduler.capacity.root.default.maximum-capacity</name>
<value>60</value>
<description>
The maximum capacity of the default queue.
</description>
</property>
<!--hive 最大资源容量占总资源80%-->
<property>
<name>yarn.scheduler.capacity.root.hive.maximum-capacity</name>
<value>80</value>
<description>
The maximum capacity of the default queue.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.root.default.state</name>
<value>RUNNING</value>
<description>
The state of the default queue. State can be one of RUNNING or STOPPED.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.root.hive.state</name>
<value>RUNNING</value>
<description>
The state of the default queue. State can be one of RUNNING or STOPPED.
</description>
</property>
<!--default队列有权限提交任务的人员-->
<property>
<name>yarn.scheduler.capacity.root.default.acl_submit_applications</name>
<value>*</value>
<description>
The ACL of who can submit jobs to the default queue.
</description>
</property>
<!--hive队列有权限提交任务的人员-->
<property>
<name>yarn.scheduler.capacity.root.hive.acl_submit_applications</name>
<value>*</value>
<description>
The ACL of who can submit jobs to the default queue.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.root.default.acl_administer_queue</name>
<value>*</value>
<description>
The ACL of who can administer jobs on the default queue.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.root.hive.acl_administer_queue</name>
<value>*</value>
<description>
The ACL of who can administer jobs on the default queue.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.root.default.acl_application_max_priority</name>
<value>*</value>
<description>
The ACL of who can submit applications with configured priority.
For e.g, [user={name} group={name} max_priority={priority} default_priority={priority}]
</description>
</property>
<property>
<name>yarn.scheduler.capacity.root.hive.acl_application_max_priority</name>
<value>*</value>
<description>
The ACL of who can submit applications with configured priority.
For e.g, [user={name} group={name} max_priority={priority} default_priority={priority}]
</description>
</property>
<!--default队列允许运行任务的最长时间,-1表示无限制-->
<property>
<name>yarn.scheduler.capacity.root.default.maximum-application-lifetime
</name>
<value>-1</value>
<description>
Maximum lifetime of an application which is submitted to a queue
in seconds. Any value less than or equal to zero will be considered as
disabled.
This will be a hard time limit for all applications in this
queue. If positive value is configured then any application submitted
to this queue will be killed after exceeds the configured lifetime.
User can also specify lifetime per application basis in
application submission context. But user lifetime will be
overridden if it exceeds queue maximum lifetime. It is point-in-time
configuration.
Note : Configuring too low value will result in killing application
sooner. This feature is applicable only for leaf queue.
</description>
</property>
<!--hive队列允许运行任务的最长时间,-1表示无限制-->
<property>
<name>yarn.scheduler.capacity.root.hive.maximum-application-lifetime
</name>
<value>-1</value>
<description>
Maximum lifetime of an application which is submitted to a queue
in seconds. Any value less than or equal to zero will be considered as
disabled.
This will be a hard time limit for all applications in this
queue. If positive value is configured then any application submitted
to this queue will be killed after exceeds the configured lifetime.
User can also specify lifetime per application basis in
application submission context. But user lifetime will be
overridden if it exceeds queue maximum lifetime. It is point-in-time
configuration.
Note : Configuring too low value will result in killing application
sooner. This feature is applicable only for leaf queue.
</description>
</property>
<!--default队列允许运行任务的默认时间,-1表示无限制-->
<property>
<name>yarn.scheduler.capacity.root.default.default-application-lifetime
</name>
<value>-1</value>
<description>
Default lifetime of an application which is submitted to a queue
in seconds. Any value less than or equal to zero will be considered as
disabled.
If the user has not submitted application with lifetime value then this
value will be taken. It is point-in-time configuration.
Note : Default lifetime can't exceed maximum lifetime. This feature is
applicable only for leaf queue.
</description>
</property>
<!--hive队列允许运行任务的默认时间,-1表示无限制-->
<property>
<name>yarn.scheduler.capacity.root.hive.default-application-lifetime
</name>
<value>-1</value>
<description>
Default lifetime of an application which is submitted to a queue
in seconds. Any value less than or equal to zero will be considered as
disabled.
If the user has not submitted application with lifetime value then this
value will be taken. It is point-in-time configuration.
Note : Default lifetime can't exceed maximum lifetime. This feature is
applicable only for leaf queue.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.node-locality-delay</name>
<value>40</value>
<description>
Number of missed scheduling opportunities after which the CapacityScheduler
attempts to schedule rack-local containers.
When setting this parameter, the size of the cluster should be taken into account.
We use 40 as the default value, which is approximately the number of nodes in one rack.
Note, if this value is -1, the locality constraint in the container request
will be ignored, which disables the delay scheduling.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.rack-locality-additional-delay</name>
<value>-1</value>
<description>
Number of additional missed scheduling opportunities over the node-locality-delay
ones, after which the CapacityScheduler attempts to schedule off-switch containers,
instead of rack-local ones.
Example: with node-locality-delay=40 and rack-locality-delay=20, the scheduler will
attempt rack-local assignments after 40 missed opportunities, and off-switch assignments
after 40+20=60 missed opportunities.
When setting this parameter, the size of the cluster should be taken into account.
We use -1 as the default value, which disables this feature. In this case, the number
of missed opportunities for assigning off-switch containers is calculated based on
the number of containers and unique locations specified in the resource request,
as well as the size of the cluster.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.queue-mappings</name>
<value></value>
<description>
A list of mappings that will be used to assign jobs to queues
The syntax for this list is [u|g]:[name]:[queue_name][,next mapping]*
Typically this list will be used to map users to queues,
for example, u:%user:%user maps all users to queues with the same name
as the user.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.queue-mappings-override.enable</name>
<value>false</value>
<description>
If a queue mapping is present, will it override the value specified
by the user? This can be used by administrators to place jobs in queues
that are different than the one specified by the user.
The default is false.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.per-node-heartbeat.maximum-offswitch-assignments</name>
<value>1</value>
<description>
Controls the number of OFF_SWITCH assignments allowed
during a node's heartbeat. Increasing this value can improve
scheduling rate for OFF_SWITCH containers. Lower values reduce
"clumping" of applications on particular nodes. The default is 1.
Legal values are 1-MAX_INT. This config is refreshable.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.application.fail-fast</name>
<value>false</value>
<description>
Whether RM should fail during recovery if previous applications'
queue is no longer valid.
</description>
</property>
<property>
<name>yarn.scheduler.capacity.workflow-priority-mappings</name>
<value></value>
<description>
A list of mappings that will be used to override application priority.
The syntax for this list is
[workflowId]:[full_queue_name]:[priority][,next mapping]*
where an application submitted (or mapped to) queue "full_queue_name"
and workflowId "workflowId" (as specified in application submission
context) will be given priority "priority".
</description>
</property>
<property>
<name>yarn.scheduler.capacity.workflow-priority-mappings-override.enable</name>
<value>false</value>
<description>
If a priority mapping is present, will it override the value specified
by the user? This can be used by administrators to give applications a
priority that is different than the one specified by the user.
The default is false.
</description>
</property>
</configuration>
重新启动yarn,我们可以看到如下2个队列,一个default队列,一个hive队列
Hadoop 概述(二)的更多相关文章
- hadoop概述测试题和基础模版代码
hadoop概述测试题和基础模版代码 1.Hadoop的创始人是DougCutting?() A.正确 B.错误答对了!正确答案:A解析:参考课程里的文档,这个就不解释了2.下列有关Hadoop的说法 ...
- Hadoop概述
本章内容 什么是Hadoop Hadoop项目及其结构 Hadoop的体系结构 Hadoop与分布式开发 Hadoop计算模型—MapReduce Hadoop的数据管理 小结 1.1 什么是Hado ...
- {MySQL数据库初识}一 数据库概述 二 MySQL介绍 三 MySQL的下载安装、简单应用及目录介绍 四 root用户密码设置及忘记密码的解决方案 五 修改字符集编码 六 初识sql语句
MySQL数据库初识 MySQL数据库 本节目录 一 数据库概述 二 MySQL介绍 三 MySQL的下载安装.简单应用及目录介绍 四 root用户密码设置及忘记密码的解决方案 五 修改字符集编码 六 ...
- Hadoop(二):MapReduce程序(Java)
Java版本程序开发过程主要包含三个步骤,一是map.reduce程序开发:第二是将程序编译成JAR包:第三使用Hadoop jar命令进行任务提交. 下面拿一个具体的例子进行说明,一个简单的词频统计 ...
- Hadoop实战之一~Hadoop概述
对技术,我还是抱有敬畏之心的. Hadoop概述 Hadoop是一个开源分布式云计算平台,基于Map/Reduce模型的,处理海量数据的离线分析工具.基于Java开发,建立在HDFS上,最早由Goog ...
- Hadoop_01_Apache Hadoop概述
一:Hadoop(Hadoop Distributed File System)概述:对海量数据分析处理的工具 1. Hadoop是Apache旗下的一个用java语言实现开源软件框架,是一个开发和运 ...
- 大数据学习笔记之Hadoop(二):HDFS文件系统
文章目录 一 HDFS概念 1.1 概念 1.2 组成 1.3 HDFS 文件块大小 二 HFDS命令行操作 三 HDFS客户端操作 3.1 eclipse环境准备 3.1.1 jar包准备 3.2 ...
- hadoop入门(1)——hadoop概述
一.hadoop生态系统特点 开源.社区活跃.涉及分布式存储和计算的整个生态系统.已得到企业界验证. hadoop1.0与2.0版本的比较: 1.0包含HDFS+MapReduce. 2.0包括HDF ...
- Hadoop 概述
Hadoop 是 Apache 基金会下的一个开源分布式计算平台,以 HDFS 分布式文件系统 和 MapReduce 分布式计算框架为核心,为用户提供底层细节透明的分布式基础设施.目前,Hadoop ...
- Hadoop系列(二)hadoop2.2.0伪分布式安装
一.环境配置 安装虚拟机vmware,并在该虚拟机机中安装CentOS 6.4: 修改hostname(修改配置文件/etc/sysconfig/network中的HOSTNAME=hadoop),修 ...
随机推荐
- 2021“MINIEYE杯”(1)
Start Time : 2021-07-20 12:10:00 End Time : 2021-07-20 17:10:00 1001-Mod, Or and Everything 真正的签到题 题 ...
- Rsync远程同步知识点总结
Rsync: 简介:是一个开源的快速备份工具.可以在不同主机之间镜像同步整个目录,支持增量备份,保持链接(硬链接.软连接)和权限,且采用优化同步算法,传输前执行压缩(传输过程中效率加快了,但是会增加c ...
- Selenium 自动化测试工具
1 介绍 Selenium是浏览器的自动化测试工具,使用它可以控制浏览器各种点击等操作. 2 环境搭建 先安装Chrome等浏览器,然后安装对应版本的ChromeDriver驱动程序,然后pip安装S ...
- weblogic历史漏洞
weblogic历史漏洞 是什么? weblogic是一个web服务器应用(中间件),和jboss一样都是javaee中间件,只能识别java语言,绝大部分漏洞都是T3反序列化漏洞 常见的中间件还 ...
- 2023NOIP A层联测20 T3 点餐
2023NOIP A层联测20 点餐 题目很好,可惜考试没想到. 思路 可以按照 \(b\) 从小到大排序,固定选择个数 \(k\),枚举选择的盘子 \(x\) 的 \(b\) 最大,最优解肯定是贪心 ...
- 2023NOIP A层联测16 T3 货物运输
2023NOIP A层联测16 T3 货物运输 题目描述说这是一个仙人掌图,通常将问题转换为环和树的问题在使用圆方树来解决. 树解法 令 \(a_i=s_i-\frac{\sum s_i}{n}\) ...
- Nuxt.js 应用中的 render:island 事件钩子
title: Nuxt.js 应用中的 render:island 事件钩子 date: 2024/12/1 updated: 2024/12/1 author: cmdragon excerpt: ...
- .NET周刊【12月第1期 2024-12-01】
我在.NET Conf China 2024 等你! .NET Conf China 2024 是一场面向开发人员的社区盛会,旨在庆祝 .NET 9 的发布,并回顾过去一年 .NET 在中国的发展成就 ...
- 数据湖加速器GooseFS,加速湖上数据分析性能
数据湖加速器 GooseFS 是由腾讯云推出的高性能.高可用.弹性的分布式缓存方案.依靠对象存储(Cloud Object Storage,COS)作为数据湖存储底座的成本优势,为数据湖生态中的计算应 ...
- 使用 VS Code 徒手构建 PDF 文件
使用 VS Code 徒手构建 PDF 文件 PDF 文件是广泛应用的页面描述文件格式,从本质上讲,文件内部的结构混合使用了文本格式描述和二进制格式描述,对于简单的文件,比如说我们今天要创建的第一个 ...