pku3668 Game of Lines】的更多相关文章

http://poj.org/problem?id=3668 水题,STL #include <stdio.h> #include <set> using namespace std; set<pair<int, int> > set1; int gcd(int x, int y) { return y? gcd(y, x%y): x; } int abs(int x) { return x<? -*x: x; } struct P { int x,…
extracting lines bases a list using awk awk 'NR==FNR{a[$1]=$0; next}($1 in a){print a[$1]"\n"$0}' file list 参考 http://521cto.blog.51cto.com/950229/945683…
画直线 题目大意:给定一些点集,要你找两点之间的连线不平行的有多少条 数据量比较少,直接暴力枚举,然后放到set查找即可 #include <iostream> #include <functional> #include <algorithm> #include <set> using namespace std; static struct _p_set { long double x, y; }points[]; set<long double&…
/** * 最多显示 $lineCount 行 * lines * * example: * @include lines; * @include lines(3); */ @mixin lines($lineCount: 2){ display: -webkit-box; -webkit-line-clamp: $lineCount; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; }…
After the last war devastated your country, you - as the king of the land of Ardenia - decided it washigh time to improve the defense of your capital city. A part of your fortication is a line of magetowers, starting near the city and continuing to t…
题意: 二维平面,给两条线段,判断形成的直线是否重合,或是相交于一点,或是不相交. 解法: 简单几何. 重合: 叉积为0,且一条线段的一个端点到另一条直线的距离为0 不相交: 不满足重合的情况下叉积为0 相交于一点: 直线相交的模板 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include &l…
题意:给两条直线,判断相交,重合或者平行 思路:判断重合可以用叉积,平行用斜率,其他情况即为相交. 求交点: 这里也用到叉积的原理.假设交点为p0(x0,y0).则有: (p1-p0)X(p2-p0)=0 (p3-p0)X(p2-p0)=0 展开后即是 (y1-y2)x0+(x2-x1)y0+x1y2-x2y1=0 (y3-y4)x0+(x4-x3)y0+x3y4-x4y3=0 将x0,y0作为变量求解二元一次方程组. 假设有二元一次方程组 a1x+b1y+c1=0; a2x+b2y+c2=0…
13.1 Write a method to print the last K lines of an input file using C++. 这道题让我们用C++来打印一个输入文本的最后K行,最直接的方法是先读入所有的数据,统计文本的总行数,然后再遍历一遍打印出最后K行.这个方法需要读两遍文件,我们想使用一种更简便的方法,只需要读取一遍文本就可以打印出最后K行,这里我们使用一个循环数组Circular Array,原理是我们维护一个大小为K的字符串数组,当数组存满后,新进来的数据从开头开始…
LINK time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In…
题目传送门 题意:判断两条直线的位置关系,共线或平行或相交 分析:先判断平行还是共线,最后就是相交.平行用叉积判断向量,共线的话也用叉积判断点,相交求交点 /************************************************ * Author :Running_Time * Created Time :2015/10/24 星期六 09:08:55 * File Name :POJ_1269.cpp *********************************…
http://poj.org/problem?id=1269 我会说这种水题我手推公式+码代码用了1.5h? 还好新的一年里1A了---- #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorithm> #include <queue> #include <…
控制台程序. import javax.swing.JComponent; import java.util.*; import java.awt.*; import java.awt.geom.*; @SuppressWarnings("serial") public class SketcherView extends JComponent implements Observer { public SketcherView(Sketcher theApp) { this.theAp…
题意:给定4个点的坐标,前2个点是一条线,后2个点是另一条线,求这两条线的关系,如果相交,就输出交点. 题解:先判断是否共线,我用的是叉积的性质,用了2遍就可以判断4个点是否共线了,在用斜率判断是否平行,最后就是相交了,求交点就好了. 求交点的过程和高中知识差不多,用y=kx+c来求,只不过要注意斜率不存在的时候特殊处理,还有就是求斜率的时候一定要强制转换,(坑爹的我,调试了一小时才找到这个bug) AC代码: #include <map> #include <set> #incl…
题目链接:http://poj.org/problem?id=1269 题目大意:给出四个点的坐标x1,y1,x2,y2,x3,y3,x4,y4,前两个形成一条直线,后两个坐标形成一条直线.然后问你是否平行,重叠或者相交,如果相交,求出交点坐标. 算法:二维几何直线相交+叉积 解法:先用叉积判断是否相交,如果相交的话,设交点坐标为p0(x0,y0).向量(p0p1)和(p0p2)的叉积为0,有(x1-x0)*(y2-y0)-(y1-y0)*(x2-x0)=0;同理,求出p0和p3p4直线的式子.…
paste - merge lines of files 命令格式: paste [OPTION] ... [FILE] ... 说明: 输出每个文件的对应行组合而成的行,中间用tab分开,如果没有FILE, 读取标准输入 -d , 行拼接时的分隔符,而不用tab -s, 交换拼接的行和列.…
Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8342   Accepted: 3789 Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three…
<!DOCTYPE html> <html lang="en"> <head> <title>three.js canvas - lines - colors</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, user-scalable=no, m…
B. Anton and Lines Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/593/problem/B Description The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforc…
题目链接 题意 : 给你两条线段的起点和终点,一共四个点,让你求交点坐标,如果这四个点是共线的,输出“LINE”,如果是平行的就输出“NONE”. 思路 : 照着ZN留下的模板果然好用,直接套上模板了事儿,不过在判断是否共线的时候,其实还有另一种方法,直接将平行和共线一起判断了,我是判断三个点三个点的判断是否是共线. #include <stdio.h> #include <string.h> #include <iostream> using namespace st…
水题,以前总结的模板还是很好用的. #include <cstdio> #include <cmath> using namespace std; ; int dcmp(double x) { ; ? - : ; } struct Point { double x, y; Point(, ):x(x), y(y) {} }; typedef Point Vector; Point read_point() { double x, y; scanf("%lf%lf"…
A Neural Network in 11 lines of Python A bare bones neural network implementation to describe the inner workings of backpropagation. Posted by iamtrask on July 12, 2015 Summary: I learn best with toy code that I can play with. This tutorial teaches b…
1614: [Usaco2007 Jan]Telephone Lines架设电话线 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 892  Solved: 399[Submit][Status] Description Farmer John打算将电话线引到自己的农场,但电信公司并不打算为他提供免费服务.于是,FJ必须为此向电信公司支付一定的费用. FJ的农场周围分布着N(1 <= N <= 1,000)根按1..N顺次编号的废弃的电话线杆,任意两…
分析:有三种关系,共线,平行,还有相交,共线和平行都可以使用叉积来进行判断(其实和斜率一样),相交需要解方程....在纸上比划比划就出来了....   代码如下: ====================================================================================================================================== #include<math.h> #include<alg…
  Counting Lines, Words, and Characters with wc   When working with text files, you sometimes get a large amount of output. Before deciding which approach works best in a specific case, you might want to have an idea about the amount of text you are…
两条直线可能有三种关系:1.共线     2.平行(不包括共线)    3.相交. 那给定两条直线怎么判断他们的位置关系呢.还是用到向量的叉积 例题:POJ 1269 题意:这道题是给定四个点p1, p2, p3, p4,直线L1,L2分别穿过前两个和后两个点.来判断直线L1和L2的关系 这三种关系一个一个来看: 1. 共线. 如果两条直线共线的话,那么另外一条直线上的点一定在这一条直线上.所以p3在p1p2上,所以用get_direction(p1, p2, p3)来判断p3相对于p1p2的关…
POJ3662 Telephone Lines 题目大意:要在顶点1到顶点n之间建一条路径,假设这条路径有m条边,其中有k条边是免费的,剩余m-k条边是要收费的, 求这m-k条边中花费最大的一条边的最小花费. 让m条边中原本花费最大的k条边成为免费的边,则这时m-k条边中花费最大的一条边的花费最小. 二分枚举m-k条边中花费最大的一条边的最小花费x,dijkstra求最短路径时,将花费大于x的边的花费设为1(花费为INF的边不变),花费小于等于x的边设为 0,则d[v-1]中返回的就是花费大于x…
Description Farmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables required to connect his farm to the phone system. There are N ( ≤ N ≤ ,) forlorn teleph…
题意:    判断直线间位置关系: 相交,平行,重合 include <iostream> #include <cstdio> using namespace std; struct Point { int x , y; Point(, ) :x(a), y(b) {} }; struct Line { Point s, e; int a, b, c;//a>=0 Line() {} Line(Point s1,Point e1) : s(s1), e(e1) {} void…
本节介绍平面划分问题,即n条直线最多把一个平面划分为几个区域(region). 问题描述: "What is the maximum number Ln of regions defined by n lines in the plane?" 这个问题最初由瑞士数学家Jacob Steiner在1826年解决. 延续上一节的解题步骤,即首先关注小规模数据,观察出结果,然后猜测一个递推式并从理论上证明,最后由递推式导出"closed form"(通项式).下面具体整理…
Anton and Lines time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Cod…