rt,计算几何入门: TOYS Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child John never puts his toys away when he is finished playing with them. They gave John a rectangular box to put his toy…
题目链接:http://poj.org/problem?id=1269 Time Limit: 1000MS Memory Limit: 10000K Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection b…
题意: 二维平面,给两条线段,判断形成的直线是否重合,或是相交于一点,或是不相交. 解法: 简单几何. 重合: 叉积为0,且一条线段的一个端点到另一条直线的距离为0 不相交: 不满足重合的情况下叉积为0 相交于一点: 直线相交的模板 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include &l…
Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 23997   Accepted: 11807 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in findi…
链接:poj 2318 题意:有一个矩形盒子,盒子里有一些木块线段.而且这些线段坐标是依照顺序给出的. 有n条线段,把盒子分层了n+1个区域,然后有m个玩具.这m个玩具的坐标是已知的,问最后每一个区域有多少个玩具 分析:从左往右.直到推断玩具是否在线段的逆时针方向为止.这个就须要用到叉积,当然能够用二分查找优化. 叉积:已知向量a(x1,y1),向量b(x2,y2),axb=x1*y2-x2*y1, 若axb>0,a在b的逆时针方向,若axb<0,则a在b的顺时针方向 注:每组数据后要多空一行…
链接: http://poj.org/problem?id=3259 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#problem/B Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 25079   Accepted: 8946 Description While exploring his many farms, Farmer…
题意:给出一个序列,求出每连续k个数字中最大的数和最小的数. 这是道单调队列裸题,直接写就行了. 本来用deque写出来后,发现在poj上硬是超时了,在discuss上看很多人也在抱怨超时的问题,据说在uestc上也有这题,我过去提交终于过了... 但是poj还是没有过,于是我用数组模拟队列来写,提交还是超时,折腾了一会,把g++改成c++终于5s多过了... 注意如果是直接输出答案的话,如果k=1可能会出错. 代码: #include <cstdio> #include <cstrin…
POJ 1973 这道题以前做过的.今儿重做一次.由于每个程序员要么做A,要么做B,可以联想到0/1背包(谢谢N巨).这样,可以设状态 dp[i][j]为i个程序员做j个A项目同时,最多可做多少个B项目.枚举最后一个程序员做多少个A项目进行转移(0/1). dp[i][j]=max{dp[i-1][k]+(time-(j-k)*a[i])/b[i]}.于是,二分时间time进行判定即可. #include <iostream> #include <cstdio> #include…
Requirements Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 3908   Accepted: 1318 Description An undergraduate student, realizing that he needs to do research to improve his chances of being accepted to graduate school, decided that it…
题目链接:http://poj.org/problem?id=3903 最长上升子序列入门题. 算法时间复杂度 O(n*logn) . 代码: #include <iostream> #include <algorithm> using namespace std; const int maxn = 100010; int n, a[maxn], f[maxn], maxlen = 0; int main() { while (cin >> n) { maxlen =…