/*
* problem: UVA 972 Horizon Line
* url: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=913
* strtege: 离散化
* Author: johnsondu
* time: 2013-4-25
*/
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std ;
#define M 10005
#define min(x, y) (x > y ? y : x)
#define max(x, y) (x > y ? x : y)
double ft[M], gt[M] ;
int n, m ;
double res ;
struct Node
{
double x, y ;
}f[M], g[M] ;
void solve ()
{
int i = 1, j = 1 ;
while (1)
{
if (ft[i] <= gt[j]) //判断覆盖范围
{
res = min(res, max(f[i].y, g[j].y)) ;
i ++ ;
}
else {
res = min(res, max(f[i].y, g[j].y)) ;
j ++ ;
}
if (i == n || j == m)
break ;
}
if (i != n) //范围判断
for (; i <= n; i ++)
res = min(res, max(f[i].y, g[m].y)) ;
if (j != m) //范围判断
for (; j <= m; j ++)
res = min(res, max(f[n].y, g[j].y)) ;
printf ("%.3lf\n", res) ;
}
int main()
{
while (~scanf ("%d", &n))
{
res = 101.0 ;
ft[0] = gt[0] = 0 ;
for (int i = 1; i <= n; i ++)
{
scanf ("%lf%lf", &f[i].y, &f[i].x) ;
ft[i] = f[i].x + ft[i-1] ;//累加时间轴
}
scanf ("%d", &m) ;
for (int i = 1; i <= m; i ++)
{
scanf ("%lf%lf", &g[i].y, &g[i].x) ;
gt[i] = gt[i-1] + g[i].x ;//累加时间轴
}
solve () ;
}
return 0 ;
}相关推荐
大型国企构建供应链创新联合体,协同研发管理为何仍是瓶颈?.docx
科易网基于行业知识库+行业大数据+科技资源要素+AI模型,以AI,赋能技术转移、成果转化、技术经理人培训、知识产权管理、区域产业分析与布局、地方科技招商、创新创业大赛等场景,推出科技创新领域的AI工具、场景化服务和数智化解决方案,推动科技创新与产业创新智能化发展。
UVA 972 Horizon Line
继续扫描线。这题我做的挺鸡肋的,离散化+扫描线了。 然后扫描线一段一段找。。 其实我觉得存成线段的那些点应该会好做点。。这么做好纠结滴说。 #include #include #include #include #include #include #incl
Adobe Illustrator 2025 29.6.0.207 m0nkrus.zip.part001
Adobe Illustrator 2025 29.6.0.207 m0nkrus.zip.part001
杭电DP题目(dynamic programming)
<br />这里集中了很多的动态规划题目,我也从这里开始突破啦<br />----------------------------------------------------------------------------------------------<br /> <br /> 记我今天开始,正式向ACM营地出发,努力搞好自己的CSDN博客<br /> <br /> turn potential to reality !<br />
Windows环境下DataEase一站式安装指南(含WSL2+Docker配置)
本文详细介绍了在Windows环境下通过WSL2和Docker快速部署DataEase的完整教程。从WSL2配置、Docker环境搭建到DataEase离线安装,逐步指导用户完成一站式部署,特别适合需要快速搭建数据分析平台的开发者。教程包含常见问题解决方案和性能优化技巧,帮助用户高效使用这款国产开源数据可视化工具。
AI工程化之生成式UI & A2UI(二)
本文介绍了生成式UI框架A2UI的架构设计与核心实现。项目采用AI协作开发模式,通过ATDD(AI驱动的测试驱动开发)确保代码质量。前端SDK基于zustand实现框架无关的状态管理,包含协议解析器、存储管理、渲染器等核心模块。重点展示了基础store构建、A2UI协议解析器的实现过程,包括mock数据准备、测试用例生成和可视化调试。项目采用monorepo管理,利用vite实现高效开发构建。整个系统设计遵循模块化原则,通过清晰的接口定义实现各组件解耦,为后续功能扩展打下基础。
HDU 1312 Red and Black
看了好多天的DFS,基本上的程序都是要借助解题报告才可以实现 但是这一题,确实依照自己的思路,完全靠自己写出来的,或许比较简单吧,所以特此发表下文章,犒劳一下自己,再接再厉 http://acm.hdu.edu.cn/showproblem.php?pid=1312 Red
一文解释电路中常用电子元器件应用和选型01
电容和二极管是电路中最常用的两个电子元器件,种类和系列众多,这里简单总结一下应用场景和选型方式 电容(Capacitor) 电容的种类(20种以上)和应用非常广泛,但是我经常遇到的无非就是下面这几种: 应用 1.隔直流。 2.旁路(去耦) 3.耦合 4.滤波 5.温度补偿 6.计时 7.调谐 8.整流 9.储能 种类 1. 陶瓷电容 2. 云母电容 3. 铝电解电容 4. 钽
杭电1051 经典贪心
这题真是抓狂,我已经提交了8次,还是没过,我都找不到任何错误数据了粘贴下别人的代码提交下,就是果断过。。。求大牛指点……/* title:Wooden Sticks url: http://acm.hdu.edu.cn/showproblem.php?pid=1051 我的做题思想: 主要是通过下表法,首先对数组的length按从小到大排序 然后,通过第一元素开始,进行比较,如果后面的任一 一组数据与当前数据进行比较,length和weight都比目前 length 和 weight 都小
FFT去除频率分量的完整流程与数学分析
重叠与窗口:确保块间无缝过渡,避免幅度跳变;实时缓冲:处理速度需快于数据输入速度,避免断流;DAC的平滑角色:通过数模转换和滤波,将离散样点还原为连续波形。通过这种分段处理+重叠拼接的方法,即使FFT本身处理的是离散数据块,最终DAC输出仍能保持信号的时间连续性。以下是完整的数学分析过程和代码逻辑,演示如何通过FFT去除特定频率成分,并通过去窗技术恢复信号。信号加窗。
NY8A053E 例程 之 PWM Ouput
更多关于NY8A053E的相关例程请留言!
Uva 10104 Euclid Problem |x|+|y|最小解 扩展欧几里得
/* * url: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1045 * stratege: 求ax+by=gcd(a,b), |x|+|y|的和的x,y,的解, 扩展欧几里得,分四种情况考虑 * status:10541367 1010
从零到一:Bioconductor新手入门与R包安装实战
本文详细介绍了Bioconductor在生物信息学中的重要性及其R包安装实战指南。从环境准备到BiocManager的使用,再到常见问题排查,帮助新手快速掌握这一强大工具。特别推荐org.Hs.eg.db等核心工具包,助力基因注释和功能分析,提升研究效率。
hdu 1930 And Now, a Remainder from Our Sponsor 扩展欧几里得 解一元线性同余方程组
/** * url : http://acm.hdu.edu.cn/showproblem.php?pid=1930 * stratege : 解一元线性同余方程组, 扩展欧几里得 * Author: johnsondu * Status: johnsondu 0MS 284K 2207B C++ 2012-08-19 13:13:15 * Trick: There will be n
基于YOLOv8的农作物病虫害检测系统设计与实现
国内如中国农业大学的科研团队采用改进的Faster R-CNN模型对小麦病害进行检测,取得了较好的效果。农作物病虫害是影响农业生产的重要因素之一,每年因病虫害导致的农作物减产高达20%-40%。YOLO(You Only Look Once)系列算法作为目标检测领域的代表性模型,以其高效、准确的特点在众多领域得到广泛应用。YOLOv8作为该系列的最新版本,在精度和速度上都有显著提升,非常适合农作物病虫害检测这类需要实时处理的应用场景。然而,现有研究仍存在一些不足:一是模型复杂度高,难以部署到移动设备;
【DeepSeek R1构建本地RAG知识库】数据结构化清洗-工作流自动清洗
在构建本地RAG知识库时,数据结构化清洗是关键但繁琐的步骤。传统方法效率低且易出错,而低代码/无代码平台如Dify提供了更高效的解决方案。Dify通过可视化工作流设计,集成大模型智能处理,支持多格式输入输出,无需编码即可完成复杂的数据清洗任务。文章详细介绍了数据结构化的核心困境、目标、价值及类型,并比较了TXT与Markdown在RAG系统中的适用性。最后,通过Dify平台实战演示了如何在20分钟内完成规则制度文档的结构化清洗,输出标准化数据,展示了自动化工作流在数据处理中的高效性和便捷性。
LightOj 1111 - Best Picnic Ever
/** * Author: johnsondu * time: 2013-4-11 * problem: LightOj 1111 - Best Picnic Ever * url: http://lightoj.com/volume_showproblem.php?problem=1111 * stratege: DFS, count the person who can r
jdk-8u144-linux-x64.tar.gz.
该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包
POJ 3641 HDU 1905 Pseudoprime numbers 素数 模取幂
/* --------------------------------------------------- status : a312745658 3641 Accepted 328K 16MS C++ 1732B 2012-05-18 21:36:37 stratege : 快速模取幂,素数筛选, 判断一个大数是否为素数 URL: http:
Probability and Statistics - 4th edition
Probability and Statistics - 4th edition
STM32F407中文手册
STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。
HDU 1211 RSA 逆元 快速模取幂
/** * url: http://acm.hdu.edu.cn/showproblem.php?pid=1211 RSA * Author: Johnsondu * Time: 2012-7-28 18:00 around * Stratege: 逆元(扩展欧几里德) , 快速模取幂 * Status: 6364213 2012-07-28 18:12:54 Accepte
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
HDU 1010 Tempter of the Bone
关于DFS如何学好,先援引大牛的几点建议: (1)先理解搜索的原理,区别好bfs和dfs的优先搜索方向以及应用,例如bfs一般用来求最优解如最短路径. (2)掌握好所用的数据结构,特别是队列. (3)牢记dfs和bfs的常用模式,它是基本固定的,考试时信手拈来! (4)注
LightOj 1054 Efficient Pseudo Code
/* * Author: johnsondu * time: 2013-4-25 * meanning: 求出约数和n ^ m的约数和,快速模取幂,扩展欧几里德,素数筛选 * problem: LightOj 1054 * url: http://lightoj.com/volume_showproblem.php?problem=1054 * */ #include #i
uva 10830 A New Function
/* * Author: johnsondu * time: 2013-4-25 * problem: uva 10830 - A New Function * url: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1771 * so
Uva 11395 - Sigma Function 规律 对数
/* * 规律:通过打表后发现,在n的范围内,只有2^x 以及 平方数 和 平方数的2倍符合要求。 * 即:2^1, 2^2,... 1*1, 2*2,... 2*1*1, 2*2*2, 2*3*3... 等等,故只要去重就可以了 * url: http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_p
HDU 1559 最大子矩阵
/** * Author : johnsondu * time : 2013-4-7 * Type: DP, I want to really understand it * problem: 最大子矩阵 * url: http://acm.hdu.edu.cn/showproblem.php?pid=1559 */ #include #include #include
NYOJ38 布线问题 prim算法 kruscal算法
/* problem : NYOJ38 布线问题 stratege: kruscal algorithm URL :http://acm.nyist.net/JudgeOnline/problem.php?pid=38 status :166386 1006100213 布线问题 Accepted 76 4216 C/C++ 05-13 21:57:42 */
POJ 3070 Fibonacci 矩阵乘法 整数分解
#include #include #include #include #include using namespace std ; int a[100][2][2] ; int n, base[30], len; void init () // 此处主要用于计算当n=1,2,4,8,16...f[n]的值,此时对应的k为0,1,2,3,... { a[0][0][0] =
990



被折叠的 条评论
为什么被折叠?



