Codeforces Round #198 (Div. 2) 题目链接:Maximal Area Quadrilateral Iahub has drawn a set of \(n\) points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also cal…
事实再一次证明:本小菜在计算几何上就是个渣= = 题意:平面上n个点(n<=300),问任意四个点组成的四边形(保证四条边不相交)的最大面积是多少. 分析: 1.第一思路是枚举四个点,以O(n4)的算法妥妥超时. 2.以下思路源自官方题解 以O(n2)枚举每一条边,以这条边作为四边形的对角线(注意:这里所说的对角线是指把四边形分成两部分的线,不考虑凹四边形可能出现的两个点在对角线同一侧的情况),以O(n)枚举每一个点,判断是在对角线所在直线的左侧还是右侧.因为被对角线分割开的两三角形不相关,所以…
Maximal Area Quadrilateral CodeForces - 340B 三点坐标求三角形面积(可以带正负,表示向量/点的不同相对位置): http://www.cnblogs.com/xiexinxinlove/p/3708147.html https://jingyan.baidu.com/article/a65957f49596ab24e67f9be7.html 枚举对角线,求出在对角线两侧取任意点能得到的三角形的面积,然后对于每条对角线,最大值就是两侧面积最大值之和. #…
B. Maximal Area Quadrilateral time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub has drawn a set of n points in the cartesian plane which he calls "special points". A quadrilateral…
[题目链接]:http://codeforces.com/problemset/problem/340/B [题意] 给你n个点,让你在这里面找4个点构成一个四边形; 求出最大四边形的面积; [题解] 枚举四边形的对角线上的对顶点; 然后再枚举每一个点; 看看这个点是在这条线的哪一侧; 是左侧和右侧; 是左侧的话; 看看这3个点构成的三角形有没有比当前获取的左侧的三角形大: 右侧的话同理; 最后把两侧得到的最大的三角形合在一起; 就是最大的四边形了; O(N 3 )  [Number Of WA…
Maximal GCD 题目链接:http://codeforces.com/contest/803/problem/C 题目大意: 给你n,k(1<=n,k<=1e10). 要你输出k个数,满足一下条件: ①这k个数之和等于n ②每个满足①条件的数列有最大公约数q,输出q最大的数列. 思路: 我们只需要找出这个最大的q是什么.q满足: ①q是n的 公约数 ②n/q>=(1+2+3+···+k) ③q是满足①②中的最大的 只需要通过for(long long i=1;i<sqrt(…
C. Maximal GCD time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2,…
Area   Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19398   Accepted: 5311 利用叉积求多边形面积,可以分解成多个三角形 利用面积公式,S=1/2*abs((x0*y1-x1*y0)+(x1*y2-x2*y1)...+(xn*yn-1-xn-1*yn)+(xn*y0-x0*yn)) ,把相邻两点和原点组成一个三角形,而总面积是这n个三角形面积的和,而三角形面积是两个相邻边向量的叉积 Descr…
http://codeforces.com/contest/1029/problem/C You are given nn segments on a number line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other o…
问有多少个点在多边形内 求一遍叉积 小于零计数就好了~ #include<stdio.h> #include<iostream> #include<algorithm> #include<math.h> #include<string.h> #include<string> #include<map> #include<set> #include<vector> #include<queue&…
题目链接:http://codeforces.com/contest/803/problem/C 中了若干trick之后才过... k个数的严格递增序列最小权值和就是${n*(n+1)/2}$,枚举这些数字增加的倍数x,使得序列变成${x,2x,3x...kx}$,然后再使最后一个数字变大满足要求就可以了,枚举的复杂度是根号$n$的. 要注意枚举倍数$x$的时候还要顺便枚举了$n/x$,然后${n*(n+1)/2}$这个东西是会爆long long的. #include<iostream> #…
http://codeforces.com/contest/803/problem/C [题意] 给定两个数n,k(1 ≤ n, k ≤ 10^10) 要你输出k个数,满足以下条件: ①这k个数之和等于n ②严格递增 ②输出的这k个数的最大公约数q尽可能大. [思路] 因为是严格递增,所以sum[k]>=k(k+1)/2,而n<=1e10,所以k应该在1e5多一点. 可以找出最大的满足n<=1e10的k,给定的k超出这个直接输出-1. 然后接下来考虑怎么使最大公约数最大: 因为q肯定也是…
题目描述: H. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a…
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is maximal. Greatest common divisor of sequence is maximum of…
枚举. 枚举对角线上放多少个$1$,剩余的贪心放,更新答案. #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cmath> #include <queue> #include <stack> #include <vector> #include <map> #include &l…
Codeforces Round #198 (Div. 2) 昨天看到奋斗群的群赛,好奇的去做了一下, 大概花了3个小时Ak,我大概可以退役了吧 那下面来稍微总结一下 A. The Wall Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can consider the wall being mad…
A. The Wall 求下gcd即可. B. Maximal Area Quadrilateral 枚举对角线,根据叉积判断顺.逆时针方向构成的最大面积. 由于点坐标绝对值不超过1000,用int比较快. C. Tourist Problem 假设序列为\(p_1,p_2,...,p_n\),则距离总和为\(,,,p_1,|p_2-p_1|,...,|p_n-p_{n-1}|\). 第1个点\(p_1\)的贡献为\(\sum a_i(n-1)!\) \(|p_i-p_{i-1}|\)的贡献为\…
总体感觉这次出的题偏数学,数学若菜表示果断被虐.不过看起来由于大家都被虐我2题居然排到331,rating又升了74.Div2-AA. The Walltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIahub and his friend Floyd have started painting a wall. Iahub is paintin…
A.The Wall 题意:两个人粉刷墙壁,甲从粉刷标号为x,2x,3x...的小块乙粉刷标号为y,2y,3y...的小块问在某个区间内被重复粉刷的小块的个数. 分析:求出x和y的最小公倍数,然后做一个一维的区间减法就可以了. #include <cstdlib> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long L…
B. Maximal Area Quadrilateral 题意:在N个点中构建四边形,使得四边形面积最大,且不自交. 分析:不自交四边形可以剖分成两个三角形,因此可以在O(N^2)内枚举对角线,然后用O(N)寻找离对角线最远的两侧的点.其实这题最快应该能到O(NlgN),求出点集的凸包,然后在凸包上转一下. C. Tourist Problem 题意:统计N!种路线的距离的均值. 分析:统计每段出现的次数,即统计(i,j)出现的次数,即统计(i_small, j_large)满足i_small…
1. Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3]. The large…
codeforces 804A Find Amir   http://codeforces.com/problemset/problem/804/A /* 题意:给定n个学校,需要遍历所有学校,可从任意一点开始. i到j有(i+j) mod (n+1) 的花费,求最小花费. 考虑贪心:先走和为n+1的两处,走完后最小只能再走到和为n+1的学校,再走到和为n的 例如: 1 2 3 4 5 6 7 8 9 10 先走1->10 花费为0 再走10->2 花费为1 再走2->9 花费为0 ..…
Screen resolution of Polycarp's monitor is a×ba×b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x,y)(x,y) (0≤x<a,0≤y<b0≤x<a,0≤y<b ). You can consider columns of pixels to be numbered from 00 to a−1a−1 , and…
Janitor Troubles Problem Description While working a night shift at the university as a janitor, you absent-mindedly erase a blackboard covered with equations, only to realize afterwards that these were no ordinary equations! They were the notes of t…
Uyuw's Concert Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 8580   Accepted: 3227 Description Prince Remmarguts solved the CHESS puzzle successfully. As an award, Uyuw planned to hold a concert in a huge piazza named after its great d…
题目链接:POJ 2451 Problem Description Prince Remmarguts solved the CHESS puzzle successfully. As an award, Uyuw planned to hold a concert in a huge piazza named after its great designer Ihsnayish. The piazza in UDF - United Delta of Freedom's downtown wa…
一个简单的用叉积求任意多边形面积的题,并不难,但我却错了很多次,double的数据应该是要转化为long long,我转成了int...这里为了节省内存尽量不开数组,直接计算,我MLE了一发...,最后看了下别人的才过,我的代码就不发了,免得误导,不得不说几何真是... 还有就是这个大神的代码,貌似G++,过不了,C++AC #include <iostream> #include <algorithm> #include <cstdio> #include <c…
D. Bicycle Race 题目连接: http://www.codeforces.com/contest/659/problem/D Description Maria participates in a bicycle race. The speedway takes place on the shores of Lake Lucerne, just repeating its contour. As you know, the lake shore consists only of s…
题目:http://poj.org/problem?id=1265 Sample Input 2 4 1 0 0 1 -1 0 0 -1 7 5 0 1 3 -2 2 -1 0 0 -3 -3 1 0 -3 Sample Output Scenario #1: 0 4 1.0 Scenario #2: 12 16 19.0 注意:题目给出的成对的数可不是坐标,是在x和y方向走的数量. 边界上的格点数:一条左开右闭的线段(x1, x2)->(x2, y2)上的格点数为:gcd( abs(x2-x1…
我们随机选取点1,2作为凸包的一个分割线,那么我们可以直接枚举剩下n-2个点找到他们和向量1-2的叉积大小与正负,然后我们可以根据叉积的正负,先将他们分割出两个区域,在向量1-2的下方还是上方,接下来找到距离向量1-2最高的点id1和最低点id2,接下来在通过向量id1-1再次分割再上方的点,同样最id2-1分割下方的点,这样就可以分割出了四个区域,最后通过叉积所得的值进行排序,因为这四个区域中的高度要么是递增要么是递减,因为题目严格保证是没有三点共线,那么这样就可以还原出来一个凸包. // —…