2017 United Kingdom and Ireland Programming(Gym - 101606)
题目很水。睡过了迟到了一个小时,到达战场一看,俩队友AC五个了。。
就只贴我补的几个吧。
B - Breaking Biscuits Gym - 101606B
旋转卡壳模板题。然后敲错了。
代码是另一种做法:对于每条边,枚举两边的所有点到直线的距离,分别取最大值,然后加起来。
#include <bits/stdc++.h>
#define FOPI freopen("in.txt", "r", stdin);
#define FOPO freopen("out.txt", "w", stdout);
using namespace std;
typedef long long LL;
const double esp = 1e-;
const int maxn = + ; struct Point
{
double x, y;
Point() {}
Point(double _x, double _y) { x = _x, y = _y; }
Point operator - (const Point &b) const
{
return Point(x-b.x, y-b.y);
}
double operator * (const Point &b) const
{
return x*b.x + y*b.y;
}
double length() { return hypot(x, y); }
};
typedef Point Vector; double cross(Vector a, Vector b) { return a.x*b.y - a.y*b.x; }
double dist(Point p, Point a, Point b)
{
return cross(p-a, b-a) / (b-a).length();
} Point a[maxn];
int n;
int main()
{
scanf("%d", &n);
for (int i = ; i <= n; i++) scanf("%lf%lf", &a[i].x, &a[i].y); double ans = 1e50;
for (int i = ; i <= n; i++)
for (int j = i+; j <= n; j++)
{
double left = 1e50, right = -1e50;
for (int k = ; k <= n; k++)
{
left = min(left, dist(a[k], a[i], a[j]));
right = max(right, dist(a[k], a[i], a[j]));
}
ans = min(ans, right-left);
} printf("%.7f\n", ans);
}
F - Flipping Coins Gym - 101606F
dp[i][j] 表示 翻了 j 次后,有 i 个正面朝上的概率。
每次翻面一定优先翻反面朝上的硬币。
那么dp[i][j]的概率可以更新 dp[i+1][j+1] 和 dp[i]j+1]。
特别的,对于 i == n, dp[i][j] 更新的是dp[i-1][j+1] 和 dp[i][j+1]
#include <bits/stdc++.h>
using namespace std;
const int maxn = + ; int n, k;
double dp[maxn][maxn]; int main()
{
scanf("%d%d", &n, &k); dp[][] = ;
for (int j = ; j < k; j++)
for (int i = ; i <= n; i++)
{
if (i == n)
{
dp[i-][j+] += 0.5*dp[i][j];
dp[i][j+] += 0.5*dp[i][j];
}
else
{
dp[i+][j+] += 0.5*dp[i][j];
dp[i][j+] += 0.5*dp[i][j];
}
} double ans = ;
for (int i = ; i <= n; i++) ans += dp[i][k] * i; printf("%.7f\n", ans);
}
L - Lizard Lounge Gym - 101606L
对于每一个人求出他和中点的斜率来,然后约分后分类,分别求LIS。
WA了一次是因为求成最长不降升子序列了。估计场上急眼了的话不好查错。
pair还是很好用的。
#include <bits/stdc++.h>
#define FOPI freopen("in.txt", "r", stdin);
#define FOPO freopen("out.txt", "w", stdout);
using namespace std;
typedef long long LL;
const int maxn = 1e6 + ;
typedef pair<int, int> prInt;
typedef pair<double, int> prDouble; int sx, sy;
int n;
int x[maxn], y[maxn];
int k[maxn];
map<prInt, int> M;
vector<prDouble> a[maxn]; int LIS(vector<prDouble> &a)
{
int tot = ;
for (int i = ; i < a.size(); i++)
{
int l = , r = tot, x = -;
while(l <= r)
{
int mid = (l+r)/;
if (k[mid] >= a[i].second) x = mid, r = mid-;
else l = mid+;
}
if (x == -) x = ++tot;
k[x] = a[i].second;
}
return tot;
} int main()
{
scanf("%d%d", &sx, &sy);
scanf("%d", &n);
int cnt = ;
for (int i = ; i <= n; i++)
{
int x, y, h;
scanf("%d%d%d", &x, &y, &h);
x -= sx, y -= sy;
int g = __gcd(abs(x), abs(y));
prInt p = prInt(x/g, y/g);
if (!M.count(p)) M[p] = ++cnt;
a[M[p]].push_back(prDouble(hypot(x, y), h));
} int ans = ;
for (int i = ; i <= cnt; i++)
{
sort(a[i].begin(), a[i].end());
ans += LIS(a[i]);
}
printf("%d\n", ans);
}
2017 United Kingdom and Ireland Programming(Gym - 101606)的更多相关文章
- Codeforces Gym101606 A.Alien Sunset (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017) 寒假第一次组队训练赛,和学长一起训练,题目难度是3颗星,我和猪队友写 ...
- 2019.04.11 第四次训练 【 2017 United Kingdom and Ireland Programming Contest】
题目链接: https://codeforces.com/gym/101606 A: ✅ B: C: ✅ D: ✅ https://blog.csdn.net/Cassie_zkq/article/ ...
- [寒假集训第一场]gym101606 2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017)
3星场 难度在于英文题面太难读懂了QAQ 看样例猜题意的我 博客园的c++主题真丑 A Alien Sunset \(description\) 有\(n\)个星球,每个星球自转时间不一样,所以一天的 ...
- 2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017)
A. Alien Sunset 暴力枚举答案即可. #include<cstdio> int n,i,mx; struct P{ int h,r,t; bool night(int x){ ...
- Codeforces Gym101606 C.Cued In (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
C Cued In 这个题是打球的.都忘了写的什么了... 代码: 1 #include<iostream> 2 #include<cstring> 3 #include< ...
- Codeforces Gym101606 J.Just A Minim (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
J Just A Minim 超级无敌大水题,但是被精度卡了一手,输出要精确到小数点后6位,我直接输出的... 代码: 1 #include<iostream> 2 #include< ...
- Codeforces Gym101606 I.I Work All Day (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
I I Work All Day 这个题就是取模找最小的. 代码: 1 #include<iostream> 2 #include<cstdio> 3 #include< ...
- Codeforces Gym101606 E.Education (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
E Education 这个题有点意思,就是找满足条件的最小价格里的最大值的人数,有点贪心的思想吧,一开始写错了,人群的那个不能排序,而且是最小价格里找能住下人最多的部门,让这个部门去住这个房间.在循 ...
- Codeforces Gym101606 D.Deranging Hat (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
D Deranging Hat 这个题简直了,本来想的是冒泡排序然后逆着输出来的,后来发现不对,因为题目上求的是最优解,而且冒泡的话,输出结果有的超出10000行了,所以就是把一开始的,排好序的字母标 ...
随机推荐
- SQL中改变列的数据类型
一.该列非主键.无default约束 直接更新: alter table 表名 alter column 列名 数据类型 二.该列为主键列.无default约束 (1)删除主键 alter table ...
- SOA框架
SOA是什么 估计很多人都听说过SOA这个词了,但是很多人还是不知道到底什么是SOA.开发人员很容易理解为是一个Web Service,但是这绝对不是SOA,那顶多只能算是SOA的一种实现方法.那么, ...
- Htpp通讯协议详解
转自:http://blog.csdn.net/gueter/archive/2007/03/08/1524447.aspx Author :Jeffrey 引言 HTTP是一个属于应用层的面向对象的 ...
- Day2下午
虽然成绩不太好,但有点进入状态了.期望200 实际160,忘记加判断了. T1 洗澡[问题描述]你是能看到第一题的friends 呢.——hja洗澡的地方,有一段括号序列,将一个括号修改一次需要1的代 ...
- PIO导出
1..HSSFWorkbook 声明一个工作簿,创建一个excel文件 //创建HSSFWork对象(excel的文档对象) HSSFWorkbook wb=new HSSFWorkbook(); / ...
- Struts2 源码分析-----Hello world
今天第一天学习struts2,没学过怎么办,那当然是helloworld.感觉嘛,学习的基本流程都差不多,就是helloworld,开发环境,然后就是逐个按照知识点打demo,打着打着你就会发现str ...
- 多个图标图片(雪碧图)使用CSS样式显示
现在的网页中显示很多图标算是常态,发现项目中页面上用到的图标都是单个图标单个文件,用的时候直接往页面上挂,这确实很常态. 如果,网站是挂在外网上,或者网速过低,又大量使用图标的情况下,由于浏览器和服务 ...
- 详细讲解:tp3.2.3生成验证码并进行验证(ajax校验返回及自定义返回)
TP3.2.3的验证码也是比较经典的小功能,框架对这个小功能的封装还是比较完美的,废话不多说,开始记录 1.总体效果: (1)初始界面 (2)自定义的返回校验效果: (3)ajax的校验返回: 2.代 ...
- java核心技术 要点笔记3
1.类,超类和子类 2.Object:所有类的超类 3.泛型数组列表 4.对象包装器和自动装箱 5.参数数量可变的方法 6.枚举类 7.反射 8.继承设计的技巧
- java Vamei快速教程20 GUI
作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! GUI(Graphical User Interface)提供了图形化的界面,允许 ...