The United Nations has decided to build a new headquarters in Saint Petersburg, Russia. It will have aform of a rectangular parallelepiped and will consist of several rectangular oors, one on top of another.Each oor is a rectangular grid of the same…
水题一题,按绝对值排序后扫描一片数组(判断是否异号,我是直接相乘注意中间值越界)即可. 感觉是让我练习sort自定义比较函数的. #include<cstdio> #include<cmath> #include<algorithm> using namespace std; const int MAXN=500000+10; int a[MAXN]; bool compare(const int &a,const int &b) { return ab…
UVA - 1605 Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu Description The United Nations has decided to build a new headquarters in Saint Petersburg, Russia. It will have a form of a rectangular parallelepiped and will cons…
传送门:https://uva.onlinejudge.org/external/6/p679.pdf 题意:在一颗结点带开关的完全二叉树上扔球,初始时开关为关闭状态,树的深度为D(1 <= D <= 20), 根结点为1(节点从1开始到2D-1),开关为关闭向左子结点走,否则往右子结点走,每到一个结点改变该结点开关状态.问第 I 颗球落在哪. 当 I 是奇数时, 它是往当前结点的左子结点走的第 (I + 1) / 2 颗球; 当 I 是偶数时, 它是往当前结点的右子结点走的第 I / 2 颗…
*注 虽然没什么人看我的博客但我还是要认认真真写给自己看 背包问题应用场景给定 n 种物品和一个背包.物品 i 的重量是 w i ,其价值为 v i ,背包的容量为C.应该如何选择装入背包中的物品,使得装入背包的总价值最大?*01 背包 *01 背包特点: 给定 n 种物品和一个背包 ( 每个物品只能选取一个).物品 i 的重量是w[i],其价值为v[i],背包的容量为C.应该如何选择装入背包中的物品,使得装入背包中的物品的总价值最大?*状态: dp[i][j] 表示在只能从 1-i 个物品中选…
Problem J Jin Ge Jin Qu [h]ao (If you smiled when you see the title, this problem is for you ^_^) For those who don't know KTV, see: http://en.wikipedia.org/wiki/Karaoke_box There is one very popular song called Jin Ge Jin Qu(劲歌金曲). It is a mix of 37…