您的位置:首页 > 其它

pku 2398

2012-03-11 11:20 204 查看
http://acm.pku.edu.cn/JudgeOnline/problem?id=2398.

敲的时候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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  string struct