BUPT OJ85 Three Points On A Line

2023-10-28 22:33
文章标签 line three points bupt oj85

本文主要是介绍BUPT OJ85 Three Points On A Line,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

题目描述

Given points on a 2D plane, judge whether there're three points that locate on the same line.

输入格式

The number of test cases  T(1T10)  appears in the first line of input.

Each test case begins with the number of points  N(1N100) . The following  N  lines describe the coordinates  (xi,yi)  of each point, in accuracy of at most 3 decimals. Coordinates are ranged in  [104,104] .

输出格式

For each test case, output Yes if there're three points located on the same line, otherwise output No.

输入样例

2
3
0.0 0.0
1.0 1.0
2.0 2.0
3
0.001 -2.000
3.333 4.444
1.010 2.528

输出样例

Yes
No

暴力



/*
USER_ID: test#birdstorm
PROBLEM: 85
SUBMISSION_TIME: 2014-03-05 21:08:58
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define For(i,m,n) for(i=m;i<n;i++)
#define MAXN 105main()
{int t, i, j, k, m, n, flag;double a[MAXN], b[MAXN];scanf("%d",&t);while(t--){flag=0;scanf("%d",&n);scanf("%lf%lf%lf%lf",&a[0],&b[0],&a[1],&b[1]);For(m,2,n){scanf("%lf%lf",&a[m],&b[m]);for(i=0;i<m-1&&!flag;i++) For(j,i+1,m)if(fabs(a[i]*b[j]-a[j]*b[i]+a[j]*b[m]-a[m]*b[j]+a[m]*b[i]-a[i]*b[m])<=1e-6) flag=1;}puts(flag?"Yes":"No");}return 0;
}


这篇关于BUPT OJ85 Three Points On A Line的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/296405

相关文章

Three 渲染器(二)

WebGL1Renderer 构造函数 WebGL1Renderer( parameters : Object ) Creates a new WebGL1Renderer. 属性 See the base WebGLRenderer class for common properties. 方法 See the base WebGLRenderer class for common

leetcode#628. Maximum Product of Three Numbers

题目 Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Input: [1,2,3]Output: 6 Example 2: Input: [1,2,3,4]Output: 24 Note: The lengt

three.js 实现围墙效果

import * as THREE from “three”; import { OrbitControls } from “three/addons/controls/OrbitControls.js”; const { innerWidth, innerHeight } = window; const aspect = innerWidth / innerHeight; class Bas

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 24 in XML document from

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 24 in XML document from class path resource [bean1.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineN

three.js使用3DTilesRendererJS加载3d tiles数据

原生的 three.js 目前不支持 3d tiles 数据的加载,不过开源社区已经给出了一些解决方案,其中最活跃的要属 3DTilesRendererJS。它为 three.js 提供了加载和调度 3d tiles 数据的基本能力,虽说和 Cesium.js 对 3d tiles 的支持相比还有很大的差距,但也比没有的好。毕竟 3d tiles 数据的加载和调度还是比较复杂的,要自己写也没那么容

Three.js new THREE.TextureLoader()纹理贴图使用png图片显示为黑色

问题代码如下: const texture = new THREE.TextureLoader().load('./image.png');droneGeometry = new THREE.PlaneGeometry(1, 1);droneMaterial = new THREE.MeshBasicMaterial({ map: texture});droneMesh = new THRE

line.split(‘ ‘).map(Number)

line.split(' ').map(Number) 是一个常见的 JavaScript 操作,分为两部分来理解: line.split(' '): 这一部分将字符串 line 按照空格 ' ' 分割成一个数组。假设 line 是 "1 2",那么 line.split(' ') 将返回 ["1", "2"],这是一个由字符串组成的数组。 .map(Number): map() 是 Jav

Command line is too long. Shorten command line for DisplayApplication (1) or

微服务项目启动类起不来,如下 解决办法:IEDA开发环境下 找到你的项目下面的.idea\workspace.xml 添加一个property : <property name="dynamic.classpath" value="true" /> 帮同事看的问题,自己测试没问题就关闭了。图片借用网上的。 参考:参考

扫描线Sweep Line算法总结

扫描线算法,推荐还是用标准的模板去写,treemap只适合于求最大的overlap个数的题目,其余的不能用treemap来解,所以推荐还是用event的思想去+1, -1然后排序扫描的方法可以用来解所有的题型; Number of Airplanes in the Sky 思路:经典扫描线算法:把interval起飞和降落做为event,全部打散,按照时间排列,同时时间相等的,按照降落在前面,起

C# 使用中点查找矩形的角(Find Corners of Rectangle using mid points)

考虑一个矩形 ABCD,我们给出了边 AD 和 BC 中点(分别为 p 和 q)的坐标以及它们的长度 L(AD = BC = L)。现在给定参数,我们需要打印 4 个点 A、B、C 和 D 的坐标。 例子:  输入:p = (1, 0)         q = (1, 2)         L = 2 输出:(0,0),(0,2),(2,2),(2,0) 解释: 打