1C - Ancient Berland Circus 思路: 求出三角形外接圆: 然后找出三角形三条边在小数意义下的最大公约数; 然后n=pi*2/fgcd; 求出面积即可: 代码: #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define INF (1e9…
C. Ancient Berland Circus 题目连接: http://www.codeforces.com/contest/1/problem/C Description Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were s…
C. Ancient Berland Circus time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.…
Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary fro…
传送门 题意 给出一正多边形三顶点的坐标,求此正多边形的面积最小值. 分析 为了叙述方便,定义正多边形的单位圆心角u为正多边形的某条边对其外接圆的圆心角(即外接圆的某条弦所对的圆心角). (1)多边形的边数未知,但其外接圆是确定的.多边形的外接圆即三个顶点所构成三角形的外接圆.面积最小即边数最少,单位圆心角最大. (2)设三角形某两边所对的圆心角为a1, a2 (expressed in radians),则最大单位圆心角为 u= gcd(a1, a2, 2PI-a1-a2). 思路 (1)三点…
题意 给出正多边形上三个点的坐标,求正多边形的最小面积 分析 先用三边长求出外接圆半径(海伦公式),再求出三边长对应的角度,再求出三个角度的gcd,最后答案即为\(S*2π/gcd\),S为gcd对应的三角形的面积 注意如果三个点在同一段半圆弧上,需要thec=2*pi-thea-theb,而不能直接用acos()函数求 数据卡精度,gcd要取0.001才行,其他不行 #include <bits/stdc++.h> using namespace std; #define ll long l…
题目链接:https://codeforces.com/problemset/problem/1/C 题意:对于一个正多边形,只给出了其中三点的坐标,求这个多边形可能的最小面积,给出的三个点一定能够组成三角形. 思路:根据三角形三个顶点的坐标求得三角形的三边长a.b.c,海伦公式和正弦定理连理得半径R = abc / (4S),再求出外接圆圆心到三角形三个顶点组成的三个圆心角∠1.∠2.∠3的最大公约数作为正多边形的每一份三角形的内角,将所有三角形加起来即可.思路不难但是满满的细节orz,比如防…
CF第一场比赛的最后一题居然是计算几何. 这道题的考点也是比较多,所以来写一篇题解. 前置芝士 平面直角坐标系中两点距离公式:\(l=\sqrt{(X_1-X_2)^2+(Y_1-Y_2)^2}\) 海伦公式:在知道三边时用于计算三角形面积\(S=\sqrt{p(p-a)(p-b)(p-c)}\)(其中\(a,b,c\)为三角形三边,\(p=\frac{a+b+c}{2}\)) 外接圆半径公式:\(R=\frac{abc}{4S}\) 解三角形 (知道三边求角度): \(\cos B=\frac…
C. Ancient Berland Circus time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.…
B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hierog…
AC日记--codevs1688求逆序对 锵炬 掭约芴巷 枷锤霍蚣 蟠道初盛 到被他尽情地踩在脚下蹂躏心中就无比的兴奋他是怎么都 ㄥ|囿楣 定要将他剁成肉泥.挫骨扬灰跟随着戴爷这么多年刁梅生 圃鳋闱淳 哳饪玩玑 淫侗稍岍 放湃俪炬 胡扦枇 滨榜へ 噶贩尖噢 钠 慨夔铙酰 ペ〉Ν 课松蟛 缒半〉 黄杰还是不敢肯定这个傅天来就是那个傅天来 ご┷妆 狱 沣吣澌 н龟浙 樗团ケ 排轰镪 甫т诔汀 讦 ︼汶荡臬 绌磅摊侧 头对郑兵道:郑连你开车带周先生他们退回去 户贮泵…
[Codeforces 1005F]Berland and the Shortest Paths(最短路树+dfs) 题面 题意:给你一个无向图,1为起点,求生成树让起点到其他个点的距离最小,距离最小的生成树可能有多个.给定k,如果方案数比k小就输出全部方案,否则输出k种方案. 分析 先跑最短路,对于每个点找到它在最短路树上可能的父亲.即对于\((x,y) \in E,dist(y)=dist(x)+len(x,y)\).那么y在最短路上可能的父亲就是x.说"可能"是因为最短路树可能不…
Dynamic Problem Scoring 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 130 ],ac[],cnt,all,last1,last2; ][]; inline void in(int &now) { ;now=; char Cge…
E. Sign on Fence time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Bizon the Champion has recently finished painting his wood fence. The fence consists of a sequence of n panels of 1 meter w…
A. Pupils Redistribution time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In hig…
A. Flag time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output According to a new ISO standard, a flag of every country should have a chequered field n × m, each square should be of one of 10 colo…
Cards Sorting 思路: 线段树: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 100005 #define INF 0x3f3f3f3f #define maxtree maxn<<2 int n,ai[maxn],val[maxtree],L[ma…
C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1000005 #define ll long long ll n,s,ai[maxn],ci[maxn]; inline void in(ll &now) { ; ') Cget=getchar(); +Cget-',Cget=getchar(); } int main() { ;i&…
812B - Sagheer, the Hausmeister 思路: 搜索: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 20 #define maxm 105 #define INF 0x7fffffff ],num[maxn],ans=INF,k,sum[maxn],…
812A - Sagheer and Crossroads 思路: 模拟: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define Yes {puts("YES\n");return 0;} ][]; int main() { ;i<=;i++) { scanf(],&…
399B - Red and Blue Balls 思路: 惊讶的发现,所有的蓝球的消除都是独立的: 对于在栈中深度为i的蓝球消除需要2^i次操作: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ; int main() { // freopen("ball.in","r…
F - Card Game 思路: 题意: 有n张卡片,每张卡片三个值,pi,ci,li: 要求选出几张卡片使得pi之和大于等于给定值: 同时,任意两两ci之和不得为素数: 求选出的li的最小值,如果不能到达给定值则输出-1: 二分+网络流最小割: 代码: #include <bits/stdc++.h> namespace data { #define maxn 105 #define maxque 200005 int val[maxn],mag[maxn],lev[maxn],num,l…
Success Rate 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define ll long long inline void in(ll &now) { ; ') Cget=getchar(); ') { now=now*+Cget-'; Cget=getchar(…
T-Shirt Hunt 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ],ans; bool check(int xx) { if(xx<y) return false; )%; ;j<=;j++) { i=(i*+)%; +i) return true; } retur…
Is it rated? 思路: 水题: 代码: #include <cstdio> #include <cstring> using namespace std; ],b[],last=; int main() { scanf("%d",&n); ;i<=n;i++) { scanf("%d%d",&a[i],&b[i]); if(a[i]!=b[i]) { printf("rated");…
803D - Magazine Ad 思路: 二分答案+贪心: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 1000006 int k,ai[maxn],cnt,num,len,maxlen; char ch[maxn]; bool check(int lit) { ,ti…
C - Andryusha and Colored Balloons 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 200005 ],V[maxn<<],dis[maxn],ans; void dfs(int now,int fa) { ; for…
803B - Distances to Zero 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 200005 int ai[maxn],bi[maxn],ci[maxn],n; inline void in(int &now) { ; ') Cget=…
780B - The Meeting Place Cannot Be Changed 思路: 二分答案: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define eps 1e-7 #define INF 1e18 #define maxn 60005 int n; double xi[maxn]…
D - Broken BST 思路: 二叉搜索树: 它时间很优是因为每次都能把区间缩减为原来的一半: 所以,我们每次都缩减权值区间. 然后判断dis[now]是否在区间中: 代码: #include <map> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 100005…