题意:
WH的方格纸,共有(w+1)(H+1)个整点,现在将2个蜡烛放在2个不同的整点上。蜡烛不会被放在边界上。现在给出方格纸的尺寸和2个蜡烛的坐标,求一条线段将方格纸拆成2部分,而且这条线段不经过任何一个蜡烛且使得每一部分恰好有一个蜡烛。问线段的起点和终点。
思路:
为了方便讨论,我们将x坐标小的设为蜡烛1,另一个设为蜡烛2.
分两种情况讨论,即横坐标相同和不同2种情况。
需要注意的是…要交文件orz
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
/* *********************************************** Author :111qqz Created Time :2017年10月02日 星期一 12时34分38秒 File Name :A.cpp ************************************************ */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <cmath> #include <cstdlib> #include <ctime> #define PB push_back #define fst first #define sec second #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define ms(a,x) memset(a,x,sizeof(a)) typedef long long LL; #define pi pair < int ,int > #define MP make_pair using namespace std; const double eps = 1E-8; const int dx4[4]={1,0,0,-1}; const int dy4[4]={0,-1,1,0}; const int inf = 0x3f3f3f3f; LL w,h,ax,ay,bx,by; int main() { freopen("anniversary.in","r",stdin); freopen("anniversary.out","w",stdout); cin>>w>>h>>ax>>ay>>bx>>by; if (ax>bx) { swap(ax,bx); swap(ay,by); } if (ax!=bx) { printf("%lld %lld %lld %lld\n",ax,0LL,ax+1,h); } else { LL my = min(ay,by); printf("%lld %lld %lld %lld\n",0LL,my,w,my+1); } return 0; } |
说点什么
您将是第一位评论人!