Codeforces Round #198 (Div. 2) —— B】的更多相关文章

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…
http://codeforces.com/contest/341 赛后做的虚拟比赛,40分钟出了3题,RP爆发. A计数问题 我们可以对每对分析,分别对每对<a, b>(a走到b)进行统计,那么这对<a, b>产生的期望为distance(a, b)/n (把这一对选出来以后相当于一个点,那么分子distance(a, b)*(n-1)!,分母n!,     (n-1)被约掉了.) 这样的算法是O(n^2)的,问题转化为统计所有对<a, b> 的距离.我们可以对输入的…
题目链接:http://codeforces.com/contest/340/problem/E E. Iahub and Permutations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub is so happy about inventing bubble sort graphs that he's sta…
D. Iahub and Xors   Iahub does not like background stories, so he'll tell you exactly what this problem asks you for. You are given a matrix a with n rows and n columns. Initially, all values of the matrix are zeros. Both rows and columns are 1-based…
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…
比赛时,开了大号去做,算了半天发现不会做A,囧.于是跑去看B,发现很水?于是很快敲完了,但是A不会,没敢交.于是去看C,一直找规律啊,后来总算调了出来,看了一下榜,发现还是算了吧,直接去睡觉了.第二天一起床把代码一交,居然A了,发现交的话rating还能涨一点,囧. B:其实就是求一个最长不下降子序列的长度.注意到数据范围,使用二分的方式求解. #include <set> #include <map> #include <list> #include <cmat…
昨天想了一下D题,有点思路不过感觉很麻烦,就懒得去敲了: 今天上午也想了一下,还是没有结果,看了一下官方题解,证明得很精彩: 这道题目其实就是一道裸地最大上升子序列的题: 看到这里,直接怒码···· #include<cstdio> #include<algorithm> using namespace std; ]; int main() { ; scanf("%d",&n); ;i<n;i++) { scanf("%d",&…
C题很容易看懂题目,不过两个循环肯定会TLE,所以得用点小聪明: 首先排好序,因为是全排列,乱序和顺序的结果是一样的: 然后呢···· 如果是数列 1 2 3 4 5 元素1 被 2 3 4 5每个减了2次,它自己减0一次:相抵后为-7: 元素2 被 3 5 4 每个减了2次,它减1两次,减0一次:相抵后为 -3: 元素3 相抵后为1: 可以发现他们的数量相差4:这样就好办了,一个循环就搞定了: 代码: #include <iostream> #include <cstdio> #…
B题是一个计算几何的题,虽然以前看过计算几何的ppt,但一直都没有写过: 昨晚比赛的时候本来想写的,但是怕不熟练浪费时间,太可惜了! 其实没必要选出一个最大的矩形: 以矩形的一条对角线为轴,向上或者向下找到最大的三角形的面积就行了, 可以看看官方的题解,讲的挺不错的! 代码: #include<cstdio> #define eps 0.00000001 using namespace std; ][]; double ccw(int x,int y,int z) { ]-a[x][])*(a…
最水的题,可惜当时赶时间没有注意数据范围:暴力超时了! 其实应该用x,y的最大公约数来判断: 代码: #include<iostream> using namespace std; int gcd(int a,int b) { ?a:gcd(b,a%b); } int main() { int x,y,a,b; cin>>x>>y>>a>>b; if(x<y) { x=x^y; y=x^y; x=x^y; } int k=x/gcd(x,y…