Rendezvous on a Tetrahedron

时间限制: 1 Sec  内存限制: 128 MB
提交: 6  解决: 4
[提交] [状态] [讨论版] [命题人:admin]

题目描述

One day, you found two worms P and Q crawling on the surface of a regular tetrahedron with four vertices A, B, C, and D. Both worms started from the vertex A, went straight ahead, and stopped crawling after a while.
When a worm reached one of the edges of the tetrahedron, it moved on to the adjacent face and kept going without changing the angle to the crossed edge (figure G.1).
Write a program which tells whether or not P and Q were on the same face of the tetrahedron when they stopped crawling.
You may assume that each of the worms is a point without length, area, or volume.

Incidentally, lengths of the two trails the worms left on the tetrahedron were exact integral multiples of the unit length. Here, the unit length is the edge length of the tetrahedron. Each trail is more than 0.001 unit distant from any vertices, except for its start point and its neighborhood.
This means that worms have crossed at least one edge. Both worms stopped at positions more than 0.001 unit distant from any of the edges.
The initial crawling direction of a worm is specified by two items: the edge XY which is the first edge the worm encountered after its start, and the angle d between the edge AX and the direction of the worm, in degrees.

figure G.2 shows the case of Sample Input 1. In this case, P went over the edge CD and stopped on the face opposite to the vertex A, while Q went over the edge DB and also stopped on the same face.

输入

The input consists of a single test case, formatted as follows.
XP YP dP lP
XQYQ dQ lQ
XWYW (W = P, Q) is the first edge the worm W crossed after its start. XWYW is one of BC,CD or DB.
An integer dW (1 ≤ dW ≤ 59) is the angle in degrees between edge AXW and the initial direction of the worm W on the face △AXWYW .
An integer lW (1 ≤ lW ≤ 20) is the length of the trail of worm W left on the surface, in unit lengths.

输出

Output YES when and only when the two worms stopped on the same face of the tetrahedron.
Otherwise, output NO.

样例输入

CD 30 1
DB 30 1

样例输出

YES

思路:将正四面体转化到二维平面,根据二维坐标找到所在的面,判断两个面是否相等。

代码如下:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=(acos(-1));
const double sq3=sqrt(3),sq32=sq3/2.0;
struct node{double x,y,angle;
};
char s[3];
int d,l;
int solve(){scanf("%s%d%d",s,&d,&l);char ch=s[0];double angle=1.0*d/180*pi;if(ch=='D') angle=2*pi-angle;else if(ch=='B') angle=5.0*pi/3-angle;else angle=4.0*pi/3-angle;node a=node{cos(angle)*l,sin(angle)*l,angle};while(a.y<-sq3){a.y+=sq3;a.x+=1;}a.x+=1,a.y+=sq3;double y=a.y*2/sq3,x=a.x-y*0.5;while(x<0) x+=2;while(x>2) x-=2;if(x<1 && y<1)        return (x+y<1)?2:1;if(1<x && x<2 && y<1) return (x-1+y<1)?3:4;if(x<1 && 1<y && y<2) return (x+y-1<1)?4:3;if(1<x && 1<y && y<2) return (x-1+y-1<1)?1:2;return -1;
}
int main(){return puts(solve()==solve()?"YES":"NO"),0;
}

View Code


转载于:https://www.cnblogs.com/acerkoo/p/9557189.html

Rendezvous on a Tetrahedron (模拟)相关推荐

  1. 软件性能测试模拟笔试题目

    欢迎关注我的公众号:造火箭的程序猿.收罗各种学习资源,分享科技趣事,推广好用但不是很大众的软件应用! 简答题(2*10=20分) 客户交付一个性能测试项目,请阐述你的实施流程. 答案: 测试设计阶段: ...

  2. 模型破碎模拟插件 RayFire for Unity

    RayFire 是一款可以在运行时对 3D 对象进行无限次拆除或切片的插件,还可在编辑模式下对其进行预粉碎. 此外,RayFire 还可对模拟对象和拆除的片段提供高级动态模拟控制功能,比如在需要时将其 ...

  3. springboot实现SSE服务端主动向客户端推送数据,java服务端向客户端推送数据,kotlin模拟客户端向服务端推送数据

    SSE服务端推送 服务器向浏览器推送信息,除了 WebSocket,还有一种方法:Server-Sent Events(以下简称 SSE).本文介绍它的用法. 在很多业务场景中,会涉及到服务端向客户端 ...

  4. curl模拟post请求

    另外可尝试 postman工具 或者用request 直接请求 CURL 发送POST请求curl -header "Content-Type: application/json" ...

  5. flask_模拟请求post,get

    #coding:utf-8 import requestsres = requests.post(url="http://192.168.135.105:8888/",data={ ...

  6. 模拟内存计算如何解决边缘人工智能推理的功耗挑战

    模拟内存计算如何解决边缘人工智能推理的功耗挑战 How analog in-memory computing can solve power challenges of edge AI inferen ...

  7. 为放大器模拟输入模块提供可靠的输入过电压保护

    为放大器模拟输入模块提供可靠的输入过电压保护 Signal Chain Basics #159: Provide robust input overvoltage protection for amp ...

  8. 模拟Servlet本质

    JavaWeb系列教程,持续更新 JavaWeb-Servlet 模拟Servlet本质 使用IDEA开发Servlet程序 Servlet对象的生命周期 适配器(GenericServlet)改造S ...

  9. 2021年大数据Flink(四十):​​​​​​​Flink模拟双十一实时大屏统计

    目录 Flink模拟双十一实时大屏统计 需求 数据 编码步骤: 1.env 2.source 3.transformation 4.使用上面聚合的结果,实现业务需求: 5.execute 参考代码 实 ...

  10. Python:模拟登录、点击和执行 JavaScript 语句案例

    案例一:网站模拟登录 # douban.pyfrom selenium import webdriver from selenium.webdriver.common.keys import Keys ...

最新文章

  1. webpack-插件机制杂记
  2. 在关于测试高速光纤链路的BICSI会前研讨会上获得3个CEC
  3. c语言如何随机获取1kb,基于VS2010+C语言实现播放器的顺序播放、随机播放
  4. 4.4 Iterator(迭代器)
  5. 使用Visual Studio 2017开发Linux程序
  6. 【测试基础】Linux文本编辑vi命令
  7. plc程序加密解密方法解读
  8. 程序员的护眼Style
  9. 彻底删除oracle数据库
  10. 汉字转拼音接口 get请求 无需注册
  11. zic2xpm - 将 ZIICS 象棋片段 (chess pieces) 转换为 XBoard (XPM/XIM) 片段的工具。
  12. Redis(五)Redis内存维护方案(过期策略及淘汰策略)
  13. 聚类分析树状图的初探
  14. google 的高级搜索
  15. LeetCode 2389. 和有限的最长子序列
  16. Lattice SII9293CNUC 接收器 集成电路IC
  17. elastic-job入门实例
  18. Mr.Alright---安兔兔、cpu-Z等三方检测apk的主频和屏幕尺寸如何修改
  19. mysql 替换pvf_【图片】pvf个人修改记录【台服dnf吧】_百度贴吧
  20. java 替换word文档中的内容

热门文章

  1. GAMS系列分享13——综合能源系统——包含储能的单能源枢纽模型
  2. java设计模式4,不要和陌生人说话
  3. 寻宝游戏(DFS+动态规划)
  4. XDOJ 317 输出完全二叉树的某一层
  5. 拆书帮第14期训练营——作业九:如何通过刻意练习来掌握临界知识
  6. 【服务器数据恢复】服务器重启后掉线硬盘重新上线同步数据被中断后数据丢失的数据恢复案例
  7. 12. JLINK在线调试+软件调试方法与技巧
  8. zz 超级拖拉机 4.02 破解算法分析
  9. 重新安装电脑系统,升级win10的系统经验总结
  10. 简介 - 有哪些冗余技术?我应该用哪个,注意什么?