UVa 12714 Two Points Revisited (水题,计算几何)
题意:给定一条线段,让你求一条线段与已知线段垂直,并且所有线段的坐标的点的坐标都不大于给定的坐标的最大值且不能为负数。
析:没啥好说的,随便找一条就好。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
//#include <tr1/unordered_map>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
//using namespace std :: tr1; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 2500 + 5;
const LL mod = 10000000000007;
const int N = 1e6 + 5;
const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
inline LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); }
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
int x1, y1, x2, y2, T;
cin >> T;
for(int kase = 1; kase <= T; ++kase){
cin >> x1 >> y1 >> x2 >> y2;
m = 0;
m = Max(m, x1); m = Max(m, y1);
m = Max(m, x2); m = Max(m, y2);
int x = x2 - x1;
int y = y2 - y1;
int xx = -y, yy = x;
int xxx = xx + x1, yyy = yy + y1;
if(xxx < 0){
x1 -= xxx;
xxx = 0;
}
if(yyy < 0){
y1 -= yyy;
yyy = 0;
}
if(xxx > m){
x1 += (m - xxx);
xxx = m;
}
if(yyy > m){
y1 += (m - yyy);
yyy = m;
}
printf("Case %d: %d %d %d %d\n", kase, x1, y1, xxx, yyy); }
return 0;
}
UVa 12714 Two Points Revisited (水题,计算几何)的更多相关文章
- UVa 11636 Hello World! (水题思维)
题意:给你一个数,让你求需要复制粘贴多少次才能达到这个数. 析:这真是一个水题,相当水,很容易知道每次都翻倍,只要大于等于给定的数就ok了. 代码如下: #include <iostream&g ...
- POJ1151 Atlantis 水题 计算几何
http://poj.org/problem?id=1151 想学一下扫描线线段树,结果写了道水题. #include<iostream> #include<cstdio> # ...
- uva 489 Hangman Judge(水题)
题目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&am ...
- uva 10252 - Common Permutation 字符串水题
题意:給定兩個小寫的字串a與b,請印出皆出現在兩字串中的字母,出現的字母由a~z的順序印出,若同字母出現不只一次,請重複印出但不能超過任一字串中出現的次數.(from Ruby兔) 很水,直接比较输出 ...
- UVa 10340 - All in All 水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVA 11947 Cancer or Scorpio 水题
Cancer or Scorpio Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://uva.onlinejudge.org/index.php? ...
- UVA 11100 The Trip, 2007 水题一枚
题目链接:UVA - 11100 题意描述:n个旅行箱,形状相同,尺寸不同,尺寸小的可以放在尺寸大的旅行箱里.现在要求露在最外面的旅行箱的数量最少的同时满足一个旅行箱里放的旅行箱的数量最少.求出这样满 ...
- UVA 11461 - Square Numbers 数学水题
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- uva 11059 maximum product(水题)——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB1QAAAMcCAIAAABo0QCJAAAgAElEQVR4nOydW7msuhKF2wIasIAHJK
随机推荐
- java打开本地应用程序(调用cmd)---Runtime用法详解
有时候我们需要借助java程序打开电脑自带的一些程序,可以直接打开或者借助cmd命令窗口打开一些常用的应用程序或者脚本,在cmd窗口执行的命令都可以通过这种方式运行. 例如: package cn.x ...
- hihoCoder #1032 : 最长回文子串 [ Manacher算法--O(n)回文子串算法 ]
传送门 #1032 : 最长回文子串 时间限制:1000ms 单点时限:1000ms 内存限制:64MB 描述 小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相 ...
- 洛谷—— P1462 通往奥格瑞玛的道路
https://www.luogu.org/problem/show?pid=1462 题目背景 在艾泽拉斯大陆上有一位名叫歪嘴哦的神奇术士,他是部落的中坚力量 有一天他醒来后发现自己居然到了联盟的主 ...
- Linux查看日志三种命令(转载)
第一种:查看实时变化的日志(比较吃内存) 最常用的: tail -f filename (默认最后10行,相当于增加参数 -n 10) Ctrl+c 是退出tail命令 其他情况: tail -n 2 ...
- Java学习--反码 原码 补码简析
关于课上实验中对小数的处理中出现的问题涉及到原码,反码,补码的问题,所以在网上进行了一下搜索.在原码,反码,补码中的解释可得知,无论是哪一种码,能够表示的数的范围是-2^(位数-1)+1至2^(位数- ...
- MySQLWorkbench里的稀奇事之timestamp的非空默认值
在创建表时,某字段为非空时间戳,timestamp not null 问题来了,使用workbench建表时,如果值非空,是需要有一个默认值的,不然会报错. 那么,如果是更新时自动填充可以使用DEFA ...
- zookeeper客户端
查看具体结点信息 bash zkServer.sh status 查看哪个结点被选作leader或者followerecho stat|nc 127.0.0.1 2181 测试是否启动了该Server ...
- 鼠标放上去Div旋转特效代码
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- python05-09
一.lambda表达式 def f1(): return 123 f2 = lambda : 123 def f3 = (a1,a2): return a1+a2 f4 = lambda a1,a2 ...
- System.Diagnostics.Debug.WriteLine 在OutPut中无输出
TextWriterTraceListener writer = new TextWriterTraceListener(System.Console.Out); Debug ...