#7 div2 B Layer Cake 造蛋糕 智商题+1】的更多相关文章

B - Layer Cake Time Limit:6000MS     Memory Limit:524288KB     64bit IO Format:%I64d & %I64u Submit Status Description Dasha decided to bake a big and tasty layer cake. In order to do that she went shopping and bought n rectangular cake layers. The l…
Description Dasha decided to bake a big and tasty layer cake. In order to do that she went shopping and bought n rectangular cake layers. The length and the width of the i-th cake layer were ai and bi respectively, while the height of each cake layer…
Layer Cake time limit per test 6 seconds memory limit per test 512 megabytes input standard input output standard output Dasha decided to bake a big and tasty layer cake. In order to do that she went shopping and bought n rectangular cake layers. The…
题意:给定 n 个矩形是a*b的,问你把每一块都分成一样的,然后全放一块,高度都是1,体积最大是多少. 析:这个题,当时并没有完全读懂题意,而且也不怎么会做,没想到就是一个暴力,先排序,先从大的开始选,如果大,那么数量少,如果小,数量就多, 用一个multiset来排序,这样时间复杂度会低一点,每一个都算一下比它的大矩阵的数量,然后算体积,不断更新,最大值. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #i…
C. Money Transfers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if…
1318: [Spoj744] Longest Permutation Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 361  Solved: 215[Submit][Status][Discuss] Description 给你一个序列A含有n个正整数(1<=Ai<=n).A的子集形式类如Au, Au+1 ... , Av (1<=u<=v<=n),即必须是连续的.我们感兴趣的是一种子集,它含有元素包括1,2,…k.(k是子…
此题就是求格点中三角形的个数. 就是找出三点不共线的个数. n*m的矩形中有(n+1)*(m+1)个格点. 选出三个点的总个数为:C((n+1)*(m+1),3). 减掉共线的情况就是答案了. 首先是水平和垂直共线的情况:C(n+1,3)*(m+1)+C(m+1,3)*(n+1); 然后斜的共线的情况就是枚举矩形. 斜着共线的三点用枚举法n*m的矩形,对角两个点中间共有gcd(m,n)-1个点,两条对角线,所以数量*2,大矩形里共有(N-n+1)*(M-m+1)个的矩形,一并去除 #includ…
题面 [正解] 一眼不可做啊 --相当于求路线上穿过的点最小距离最大 最小最大--二分啊 现在相当于给一个直径,要判断这个直径是否能从左边穿到右边 我们可以在距离不超过直径的点连一条边,\(y=0\)和\(y=L\)建虚点,然后判断他们是否连通,如果连通说明不能通过 复杂度\(O(N^2 log(L/eps))\) 实际上,这就是求两个虚点的最小瓶颈路的过程 也可以跑一遍最小生成树,在连通的时候输出加上的那条边 复杂度\(O(N^2 log(N^2))\),应该差不多 代码…
题目传送门:http://codeforces.com/contest/957/problem/D 题意大致是这样的:有一个水池,每天都有一个水位(一个整数).每天都会在这一天的水位上划线(如果这个水位已经被划线了,那么不划线). 现在告诉你每天能看见的线条mi(就是高于水面的,刚好在水面的不算),设di为第i天水面以下的线条数(刚好在水面的不算),求(d1+d2+d3....dn)的最小值. 解析: 我们设第i天有ki条水位线,容易得到: 移项后,将d留在右边,我们发现mi和n都是固定的,所以…
题意 题目链接 Sol 我的思路:直接按样例一的方法构造,若$h \times w$完全被$N \times M$包含显然无解 emm,wa了一发之后发现有反例:1 4 1 3 我的会输出[1 1 -3 1] 好吧,题解的操作确实骚,考虑我们为什么会wa.因为总和相加为正数这个条件没有被满足 现在我们要保证每个数都满足要求的基础上增大每个子矩阵对答案的贡献 直接让每个数扩大1000倍即可 对于1 4 1 3来说,[1000 1000 -2001 1000]显然合法. 做完了.. #include…