Ural 1258 镜面对称
2024-08-29 20:31:08
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std; const double eps = 1e-;
const double PI = acos(-1.0);
const double INF = 1000000000000000.000; struct Point{
double x,y;
Point(double x=, double y=) : x(x),y(y){ } //构造函数
};
typedef Point Vector; Vector operator + (Vector A , Vector B){return Vector(A.x+B.x,A.y+B.y);}
Vector operator - (Vector A , Vector B){return Vector(A.x-B.x,A.y-B.y);}
Vector operator * (double p,Vector A){return Vector(A.x*p,A.y*p);}
Vector operator / (Vector A , double p){return Vector(A.x/p,A.y/p);} bool operator < (const Point& a,const Point& b){
return a.x < b.x ||( a.x == b.x && a.y < b.y);
} int dcmp(double x){
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
bool operator == (const Point& a, const Point& b){
return dcmp(a.x - b.x) == && dcmp(a.y - b.y) == ;
} ///向量(x,y)的极角用atan2(y,x);
inline double Dot(Vector A, Vector B){ return A.x*B.x + A.y*B.y; }
inline double Length(Vector A) { return sqrt(Dot(A,A)); }
inline double Angle(Vector A, Vector B) { return acos(Dot(A,B) / Length(A) / Length(B)); }
double Cross(Vector A, Vector B) { return A.x*B.y - A.y * B.x; } Point read_point(){
Point A;
scanf("%lf %lf",&A.x,&A.y);
return A;
} /*************************************分 割 线*****************************************/ int main()
{
//freopen("E:\\acm\\input.txt","r",stdin);
double W,D;
Point S,T;
char s[]; scanf("%lf %lf",&W,&D);
double x,y;
scanf("%lf %lf",&x,&y);
S = Point(-x,y);
scanf("%lf %lf",&x,&y);
T = Point(-x,y);
scanf("%s",s);
int len = strlen(s); for(int i=;i<len;i++){
if(s[i] == 'F'){
S.y = -S.y;
}
else if(s[i] == 'L'){
S.x = -S.x;
}
else if(s[i] == 'B'){
S.y = *D -S.y;
}
if(s[i] == 'R'){
S.x = -*W-S.x;
}
//cout<<S.x<<" "<<S.y<<endl;
}
double ans = Length(S-T); printf("%.4lf\n",ans);
}
最新文章
- tomcat server.xml中文版
- Vue基础理论
- View (二) 自定义属性 自定义属性的格式详解
- eclipse项目中启动项目无法载入类
- jquery的$.extend和$.fn.extend作用及区别
- Nginx 1.4.7图片缓存服务器
- YII中路径别名
- 如何在一个网站或者一个页面,去书写你的JS代码
- FusionCharts使用问题及解决方法(二)-FusionCharts常见问题大全
- JAVA基础知识(一)—JAVA概述
- Oracle SQL*Plus命令
- Neo4j导入本地csv问题
- dedecmsv5.7 ueditor编辑器上传视频/修改,视频显示空白,解决方案
- GO中DEFER的理解--DEFER执行的原理
- 2018.12.29 codeforces 940E. Cashback(线性dp)
- Ajax发送POST请求对数据的封装
- 【读书笔记】Linux内核设计与实现(第一章&;第二章)
- java NIO系列教程1
- redis live 如何安装
- JAXB简单样例