Title: give you a few square side length, square a vertex on the x-axis and then the angle of the x-axis is 45 degrees, each square is close, ask from above to see the number of squares can see
Topic ideas: Line coverage, edge length multiply on 2 to prevent the generation of decimals, to find out each square and x-axis parallel diagonal of the starting x-coordinate, the rest is the line.
#include <cstdio>#include<cstdlib>#include<cmath>#include<iostream>#include<algorithm>#include<cstring>#include<vector>#include<queue>#defineINF 0x3f3f3f3f#defineMAX 100005using namespacestd;structnode{intSx,y,ex,dist;} Point[max];intVis[max],n;voidFind (intSxintExintPOS) { for(intI=0; i<n; i++) { if(I==pos | | (Point[pos].y >=point[i].y)) Continue; if((sx>=point[i].sx && ex<=point[i].ex) | | sx>=ex) {Vis[pos]=1; return; } Else if(Sx<=point[i].ex && sx>=point[i].sx) {SX=Point[i].ex; } Else if(Ex<=point[i].ex && ex>=point[i].sx) {Ex=point[i].sx; } }}intMain () {intD,sx,ex; intop; while(SCANF ("%d",&N), N) {op=0; memset (Vis,0,sizeof(VIS)); for(intI=0; i<n; i++) {scanf ("%d",&d); Point[i].dist=D; Point[i].y=D; POINT[I].SX=0; for(intj=0; j<i; J + +) {point[i].sx=max (Point[i].sx,point[j].ex-abs (point[i].dist-point[j].dist)); } Point[i].ex=point[i].sx+2*D; } for(intI=0; i<n; i++) {ex=Point[i].ex; SX=point[i].sx; Find (Sx,ex,i); } for(intI=0; i<n; i++) { if(!Vis[i]) { if(!op) {op=1; printf ("%d", i+1); } Elseprintf ("%d", i+1); }} printf ("\ n"); } return 0;}
View Code
POJ 3347 Kadj Squares (segment overlay)