pku 2398
2012-03-11 11:20
204 查看
http://acm.pku.edu.cn/JudgeOnline/problem?id=2398.
敲的时候sb掉了。。写数论习惯性的是 unsigned __int64 u64..于是乎也贴了上去...于是乎。。因为unsigned.......
敲的时候sb掉了。。写数论习惯性的是 unsigned __int64 u64..于是乎也贴了上去...于是乎。。因为unsigned.......
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <math.h> #include <time.h> #include <set> #include <map> #include <stack> #include <queue> #include <string> #include <bitset> #include <vector> #include <deque> #include <utility> #include <list> #include <sstream> #include <iostream> #include <functional> #include <numeric> #include <algorithm> using namespace std; template<class T>inline T iabs(const T& v) {return v<0 ? -v : v;} template<class T>inline T strTo(string s){istringstream is(s);T v;is>>v;return v;} template<class T>inline string toStr(const T& v){ostringstream os;os<<v;return os.str();} inline double max(double x, double y) {return x > y? x : y;} inline double min(double x, double y) {return x < y? x : y;} #define CLR(arr,v) memset(arr, v, sizeof(arr)) #define SQ(a) ((a)*(a)) #define DEBUG(a) printf("%s = %s\n", #a, toStr(a).c_str()) #define FOR(i,s,e) for( int (i)=(s); (i) < (e) ; i++) typedef __int64 u64; const double EP = 1E-3 ; const double INF = 1E10; /* 基本几何结构 */ struct POINT { u64 x; u64 y; }; struct LINESEG { POINT s; POINT e; LINESEG(POINT a,POINT b) {s = a; e =b;} LINESEG(){} }; LINESEG line[1010]; POINT toy[1010]; int sign[1010]; int n; int m; u64 multiply(POINT sp, POINT ep, POINT op) { return ((sp.x-op.x)*(ep.y-op.y) - (ep.x-op.x)*(sp.y-op.y) ); } bool judge(int i, int j) { if ( multiply(line[i].s, toy[j], line[i].e ) > 0 && multiply(line[i+1].s,toy[j], line[i+1].e ) < 0 ) return true; return false; } bool cmp(LINESEG a, LINESEG b) { if (a.e.x < b.e.x ) return true; if (a.e.x == b.e.x && a.s.x < b.s.x) return true; return false; } int main() { while (scanf("%d",&n)!=EOF,n>0) { CLR(sign,0); u64 xl,yl,xr,yr; scanf("%d%I64d%I64d%I64d%I64d",&m,&xl,&yl,&xr,&yr); FOR(i,0,n+2) { line[i].e.y = yl; line[i].s.y = yr; } line[0].s.x = line[0].e.x =xl; line[n+1].e.x = line[n+1].s.x = xr; FOR(i,1,n+1) { u64 u1,u2; scanf("%I64d%I64d",&u1,&u2); line[i].e.x = u1; line[i].s.x = u2; } n=n+2; FOR(i,0,m) scanf("%I64d%I64d",&toy[i].x,&toy[i].y); sort(line,line+n,cmp); FOR(i,0,n-1) { u64 sum = 0; FOR(j,0,m) if (judge(i,j)) sum++; sign[sum]++; } printf("Box\n"); FOR(i,1,m+1) if (sign[i]!=0) { printf("%d: %d\n",i,sign[i]); } } return 0; }
相关文章推荐
- 【解题报告】PKU 2318 TOYS AND PKU 2398 Toy Storage
- pku 1228 Grandpa's Estate .cpp
- POJ 2398 叉积应用
- PKU 1083 Moving Tables
- PKU 1195 二维树状数组
- pku3273 Monthly Expense
- pku 3691 DNA repair AC自动机——DP
- pku2945 Find the Clones
- pku1200 Crazy Search
- PKU-3723(Kruskal())
- pku 3070 矩阵快速幂
- PKU-1011 Sticks (DFS + 剪枝)
- PKU1679(The Unique MST)判断最小生成树的唯一性-次小生成树
- pku_2155_Matrix
- pku2240 Arbitrage
- pku1061 青蛙的约会
- pku 1742 Coins(多重背包dp)
- pku 2187 Beauty Contest(凸包+卡壳旋转)
- PKU并查集,秩的运用
- pku 1830 开关问题(构造矩阵+高斯消元)