Little Sub and Triangles(叉积+二分查找)

STL文件解析与OpenGL显示:从零实现3D模型查看器 三角形网格是3D图形与CAD领域的基石,而STL格式凭借其结构简单、解析门槛低,成为入门网格处理的最佳选择。理解STL文件的二进制与ASCII结构,掌握顶点数据的高效组织方式,是后续进行模型渲染、切片或检测的基础。在图形学中,OpenGL作为跨平台的渲染API,通过VAO/VBO将CPU端的顶点数据上传至GPU,配合着色器计算光照与投影,即可在屏幕上呈现具有立体感的模型。这套流程广泛应用于3D打印预览、工业零件轻量化查看以及游戏资源预览等场景。本文从STL文件格式的细节出发,深入解析顶点法线计算、索引绘制优 阅读详情

题目: Little Sub and Triangles

题意:Refusing
Refusing
数据:
4 2
0 1
100 100
0 0
1 0
0 50
0 2
思想:因为最多只用250个点,通过O(N^3)把所有的三角形面积求出来,通过二分查找,找到答案。
叉积公式:S=abs(x1y2+x2y3+x3y1-x1y3-x2y1-x3y2) /2;
代码:

#include<bits/stdc++.h>
using namespace std;
const int num = 255;
#define LL long long
struct Node
{
    LL x, y;
} a[num];

vector<LL>v;
int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    for(int i = 0; i < n; i++)
    {
        scanf("%lld %lld", &a[i].x, &a[i].y);
    }
    v.clear();
    for(int i = 0; i < n-2; i++)
    {
        for(int j = i+1; j < n-1; j++)
        {
            for(int k = j+1; k < n; k++)
            {
                LL ans = abs(a[i].x*a[j].y + a[j].x*a[k].y+a[k].x*a[i].y-a[i].x*a[k].y-a[j].x*a[i].y-a[k].x*a[j].y);//叉积
                v.push_back(ans);
            }
        }
    }
    sort(v.begin(), v.end());
    LL l, r;
    for(int i = 1; i <= q; i++)
    {
        scanf("%lld %lld", &l, &r);
        LL pos = upper_bound(v.begin(), v.end(), r*2) - lower_bound(v.begin(), v.end(), l*2);//二分查找,因为上面的结果没有除以2,所以l,r乘以2
        printf("%lld\n", pos);
    }

    return 0;
}

人脸关键点定义汇总 前几天看一份代码临时需要找49个人脸关键点位置定义的图片发现怎么百度都搜不到,最后幸好谷歌可以使用了就用谷歌搜到了。所以在这里汇总一下我所知道的人脸关键点的定义和相关的一点东西,以备不时之需。 68个关键点 最常用的工具是Dlib,网址:http://dlib.net/ dlib的68个特征点检测算法是ERT算法【1】 使用dlib检测68个特征点的python示例见:http://dlib.n... 阅读详情

相关推荐

Debian 11 下用hostapd+dnsmasq搭建WiFi热点:从命令行到实战(避坑指南)

本文详细介绍了在Debian 11系统上,使用hostapd和dnsmasq从命令行搭建稳定WiFi热点的完整实战流程。内容涵盖环境准备、无线网卡AP模式检查、服务深度配置,并重点提供了从服务启动失败到客户端无法上网等常见问题的系统性排错指南,帮助用户避开配置陷阱,成功创建可用的无线接入点。

CAT789的专栏 770

2019年杭州师范大学第十二届程序设计竞赛 H:Little Sub and Counting(简单数学题)

Little Sub and Counting 【题目】 Little Sub and Counting Time Limit:1 s Memory Limit: 256 MB Submission:1587 AC:150 Score:100.00 SubmitCodes Description Little Sub likes Math. No...

菜鸡成长史 429

统一大型语言模型和知识图谱:路线图

大型语言模型(LLM),如ChatGPT和GPT4,由于其涌现能力和泛化性,正在自然语言处理和人工智能领域掀起新的浪潮。然而,LLM是黑箱模型,通常无法捕捉和获取事实知识。相反,知识图谱(KGs),例如维基百科和华普,是显式存储丰富事实知识的结构化知识模型。KGs可以通过为推理和可解释性提供外部知识来增强LLM。同时,KGs很难从本质上构建和演化,这对KGs中现有的生成新事实和表示未知知识的方法提出了挑战。因此,将LLM和KGs统一在一起并同时利用它们的优势是相辅相成的。

qq_32907491的博客 2841

【BZOJ1939】[Croatian2010] Zuma(动态规划)

题目: BZOJ1939(权限题) 分析: 这题很容易看出是DP,但是状态和转移都不是很好想…… 用dp[l][r][c]dp[l][r][c]dp[l][r][c]表示在lll前面已经新加了ccc个和lll一样的弹子时,使区间[l,r][l,r][l,r]消完所需插入的弹子数量 显然,当c≥k−1c\geq k-1c≥k−1时,这ccc个弹子和lll组成了连续的至少kkk个弹子,这些情况是类似的...

Inspector_Javert 426

DRM驱动架构浅析-上(DRM基础概要与U-Boot阶段驱动解析)

本文主要探讨了Rockchip平台的DRM显示驱动架构及其在U-Boot阶段的实现。

一路寒风身如絮,命海沉浮客独行 1761

Win11下USB-Blaster驱动安装全攻略:Quartus用户必看(附常见问题解决)

本文详细介绍了在Windows 11系统下为Intel FPGA开发工具Quartus安装USB-Blaster驱动的完整流程与常见问题解决方案。针对Win11更严格的驱动签名验证机制,提供了从标准安装步骤到高级故障排查(如禁用驱动强制签名、使用测试模式)的实用指南,帮助用户快速解决驱动安装失败问题,确保FPGA编程调试顺利进行。

weixin_29256771的博客 657

LeetCode 488 Zuma Game 解题报告

原文链接: http://hankerzheng.com/blog/Leetcode-Zuma-Game-Problem DescriptionLeetCode 488 Zuma Game You have a row of balls on the table, colored red(R), yellow(Y), blue(B), green(G), and white(W).

hanzheng992的博客 3087

基于 MATLAB 的综合能源系统建模:全面解析与案例应用 

本文详细介绍了基于 MATLAB 的综合能源系统建模相关知识,包括 MATLAB 在综合能源建模中的优势、综合能源系统各组件和网络的建模方法,并通过园区综合能源系统的案例展示了从建模到优化调度求解以及结果分析的全过程。在当今全球能源格局深刻变革的背景下,综合能源系统(Integrated Energy System,IES)作为一种创新的能源供应体系,整合了多种能源形式,如电力、热力、燃气等,以实现能源的高效生产、传输、分配和利用。需要考虑燃气的压力、流量特性以及管道的阻力特性等。

qq_57128262的博客 1334

Little Sub and Triangles

http://acm.hznu.edu.cn/OJ/problem.php?cid=1263&amp;pid=10 http://acm.hznu.edu.cn/OJ/problem.php?id=2589 题解:暴力求面积*2 二分 /* *@Author: STZG *@Language: C++ */ #include &lt;bits/stdc++.h&gt; #inc...

无限迭代中...... 822

使用Python爬虫抓取旅游景点评价数据并进行热度可视化

景点热度通常由景点的评分、评论数以及游客的热情度来决定。高热度的景点通常意味着更高的游客评分和更多的游客评论。热度不仅反映了景点的受欢迎程度,还可以揭示某些景点的潜力和存在的问题。评分:游客对景点的综合评分,通常是0到5分。评论数:景点的评论数量,反映了游客对景点的关注程度。热度变化:在一定时间内,景点的评价和评论数量变化,能够反映景点的热度波动。通过使用Python爬虫技术抓取旅游景点的评价和评论数据,我们能够深入分析景点的热度,并通过数据可视化工具将这些信息展示给用户。

2201_76125261的博客 1282

[QMT量化交易小白入门]-四、如何筛选优质可转债,并进行下单操作

通过上述步骤,成功地使用Python代码完成了可转债的筛选、数据处理和下单操作。当然,这只是一个基础的示例,实际投资中还需要考虑更多因素,如市场环境、资金管理、风险控制等。希望本文能为各位投资者提供一些有价值的参考,助力大家在投资道路上走得更远。

木头大左的博客 1728

Little Sub and Triangles(向量叉积)

题目描述 Little Sub loves triangles. Now he has a problem for you. Given n points on the two-dimensional plane, you have to answer many queries. Each query require you to calculate the number of triangles...

eazo的博客 409

高通开发系列 - Bootloader之lk匹配dtb和dtbo中msm-id和board-id的知识

lk匹配dtb和dtbo中的msm-id和board-id等知识

fulinux的博客 4244

问题 K: Little Sub and Triangles

题目链接 题目描述 Little Sub loves triangles. Now he has a problem for you. Given n points on the two-dimensional plane, you have to answer many queries. Each query require you to calculate the number of tria...

王小平 790

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

UPC Contest 1748 Little Sub and Triangles

题目描述 Little Sub loves triangles. Now he has a problem for you. Given n points on the two-dimensional plane, you have to answer many queries. Each query require you to calculate the number of triangle...

ytuyzh的博客 293

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

HZNU2019校赛-Little Sub and Triangles(小撒布与三角形)(二分答案)

Description Little Sub loves triangles. Now he has a problem for you. 小撒布喜欢三角形。现在他有一个问题要给你。 Given n points on the two-dimensional plane, you have to answer many queries. Each query require you to c...

Untersee-boot XXI 295

深度学习工具包 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');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

2019年杭州师范大学第十二届程序设计竞赛 K:Little Sub and Triangles(三角形面积公式+二分)

Little Sub and Triangles 【题解】 数学太差推错公式orz 已知三角形三个顶点坐标求三角形面积公式:S=0.5*fabs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1)) 遍历求出所有三角形的面积,排序二分统计个数即可。 【代码】 #include <cstdio> #include <iostream> #includ...

菜鸡成长史 379

2019杭州师范大学校赛 问题 K: Little Sub and Triangles

问题 K: Little Sub and Triangles 时间限制: 2 Sec 内存限制: 256 MB 提交: 427 解决: 76 [提交] [状态] [命题人:admin] 题目描述 Little Sub loves triangles. Now he has a problem for you. Given n points on the two-dimensional plan...

Kris_Kris的博客 276

UVa OJ 题解索引

寂静山林 740

BFS(广度优先搜索)简单例题(一)

bfs想必非常的熟悉了,bfs大多数用来解决什么问题呢?一个最直观经典的例子就是走迷宫,我们从起点开始,找出到终点的最短路程,很多最短路径算法就是基于广度优先的思想成立的。所以这篇博客,主要是利用bfs找迷宫的最短距离。首先看看bfs一般的使用套路: Problem 2285 迷宫寻宝 链接:http://acm.fzu.edu.cn/problem.php?pid=2285 本题就是一...

REfusing的博客 1万+

求数组(连续)在某一区间最大值(简单的动态规划的思想)

举个例子:9  -18 3 2 7 1在求这串维数组(连续)区间的最大值的时候,最开始的想法就是暴力,把每个区间的数都加在一起,然后再比较出最大的数,这种方法虽然可以做出来,但是太浪费时间了,所以就有了一个比较简单的想法动态规划的思想。先整一段代码瞅瞅: #include&lt;stdio.h&gt; #include&lt;iostream&gt; #include&lt;string.h&...

REfusing的博客 5317

欧拉回路,欧拉通路的判断方法

基本定义以及判断方法:图片截取自博客HDU1878——欧拉回路(并查集) 例题1:欧拉回路 代码: //本题为无向图的欧拉回路 //欧拉回路:图连通;图中所有节点度均为偶数 #include<string.h> #include<stdio.h> using namespace std; const int maxn = 1050; int F[maxn], d...

REfusing的博客 4279

搜索学习

题目: 排列数字 题意:就是让你输出全排列。 思路:可以用dfs去搜索。 代码:数组标记 #include<bits/stdc++.h> using namespace std; const int maxn = 10; int pri[maxn], n, vis[maxn]; void dfs(int step){ if(step == n){ for(in...

REfusing的博客 2360

费马大定理

本篇博客主要讲解费马大定理这个比较牛掰的定理——费马大定理,为什么这么牛掰呢,因为这个问题困扰了困扰了整个世界三百多年,直到上个世纪90年代终于被牛掰的人安德鲁·怀尔斯给证明出来。 那么这个牛掰的定理讲的是啥? 这就是困扰世界三个多世纪的问题,瞅着是不是挺简单的,但是证明那就呵呵了,在下能力有限,就不给大家写证明的过程了,只要求大家知道费马大定理就是了。 题目:Find Integer 题意:给...

REfusing的博客 2293

最短路径《二》

P1339 [USACO09OCT]热浪Heat Wave 链接:https://www.luogu.org/problemnew/show/P1339 题意:把牛奶从一个地方运输另外一地方的路程最短,把这个最短的路程输出来。 题解:本题就是典型的单源最短路径的问题,本题我用的是SPFA算法. #include&lt;stdio.h&gt; #include&lt;iostream&gt...

REfusing的博客 2261

小猫爬山(简单的dfs)

题目:小猫爬山 思路:本题从题意中,很容易但出来是DP但是数据范围很大,所以就把DP排除了,所以我们就想到用dfs,把猫的重量按照从大到小的顺序,先把的先放一个车子里,然后把不断的去把小的是否能和大的放在一个车子里,我门有两种方案,一种是放在已有的车子里,如果放不下,那么我门就重新申请一辆车子。 代码: #include<bits/stdc++.h> using namespace s...

REfusing的博客 1791
上一篇: 强连通分量Tarjan
下一篇: 数论知识点整理
Re:fused
博客等级 码龄9年 474粉丝 162原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值