A very troublesome problem, there are a lot of tricks to learn
#include <Set>#include<cstdio>#include<iostream>#include<algorithm>using namespaceStd;typedefLong LongLL;Const intMAXN =100005;Const intINF =0x3fffffff;Const intK =2520;//LCM (,..,);intw,h;structnode{intPOS; intdir; FriendBOOL operator<(node A,node b) {if(A.pos==b.pos)returnA.dir>B.dir; returna.pos<B.pos; }}E[MAXN*2];voidSolveintXintAintWint&l,int&R) { if(a==0){ if(x<=0|| X>=W) R = L1; } Else if(a>0) {L= Max (l,-x/a); R= Min (r, (w-x)/a); } Else{L= Max (L, (w-x)/a); R= Min (r,-x/a); }}intMain () {//freopen ("In.txt", "R", stdin); intT;SCANF ("%d",&T); while(t--) { intN;SCANF ("%d%d%d",&w,&h,&N); W*=k;h*=K; intCNT =0; for(inti =1; i<=n;++i) {intx,y,a,b; scanf ("%d%d%d%d",&x,&y,&a,&C); intL =0, r =INF; Solve (x*k,a,w,l,r); Solve (y*k,b,h,l,r); if(r<=l)Continue; E[cnt+ +] = (node) {L,0}; E[cnt+ +] = (node) {R,1}; } sort (E,e+CNT); intAns =0, t =0; for(inti =0; i<cnt;++i) {if(E[i].dir) t--; Elset++; Ans=Max (ans,t); } printf ("%d\n", ans); } return 0;}
LA3905 Meteor (Meteor)