CF630M.Turn
普及+/提高
通过率:0%
时间限制:0.50s
内存限制:64MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vasya started working in a machine vision company of IT City. Vasya's team creates software and hardware for identification of people by their face.
One of the project's know-how is a camera rotating around its optical axis on shooting. People see an eye-catching gadget — a rotating camera — come up to it to see it better, look into it. And the camera takes their photo at that time. What could be better for high quality identification?
But not everything is so simple. The pictures from camera appear rotated too (on clockwise camera rotation frame the content becomes rotated counter-clockwise). But the identification algorithm can work only with faces that are just slightly deviated from vertical.
Vasya was entrusted to correct the situation — to rotate a captured image so that image would be minimally deviated from vertical. Requirements were severe. Firstly, the picture should be rotated only on angle divisible by 90 degrees to not lose a bit of information about the image. Secondly, the frames from the camera are so huge and FPS is so big that adequate rotation speed is provided by hardware FPGA solution only. And this solution can rotate only by 90 degrees clockwise. Of course, one can apply 90 degrees turn several times but for the sake of performance the number of turns should be minimized.
Help Vasya implement the program that by the given rotation angle of the camera can determine the minimum number of 90 degrees clockwise turns necessary to get a picture in which up direction deviation from vertical is minimum.
The next figure contains frames taken from an unrotated camera, then from rotated 90 degrees clockwise, then from rotated 90 degrees counter-clockwise. Arrows show direction to "true up".

The next figure shows 90 degrees clockwise turn by FPGA hardware.

瓦西娅开始在IT城市的一家机器视觉公司工作。瓦西娅所在的团队开发用于人脸识别的软硬件系统。
该项目的一项核心技术是:摄像头在拍摄过程中绕其光轴旋转。人们看到这个引人注目的装置——一个旋转的摄像头——便会主动靠近,以便更清楚地观察它,并朝镜头中看去;此时摄像头便捕捉下他们的照片。还有什么比这更能保证高精度识别呢?
但事情并非如此简单。由于摄像头顺时针旋转,所拍摄图像的内容反而会逆时针旋转。而识别算法仅能处理与竖直方向偏差极小的人脸图像。
瓦西娅被委以重任:对捕获的图像进行旋转校正,使其尽可能接近竖直方向。要求非常严格:
第一,图像只能按90度的整数倍角度旋转,以避免丢失任何图像信息;
第二,摄像头输出的帧尺寸极大、帧率极高,唯有硬件FPGA方案才能满足足够的旋转速度;而该FPGA方案仅支持顺时针旋转90度。当然,可多次应用90度顺时针旋转,但出于性能考虑,应使旋转次数最小化。
请帮助瓦西娅编写一个程序:给定摄像头的旋转角度,确定所需的最少90度顺时针旋转次数,使得最终图像中“上”方向相对于竖直方向的偏差最小。
下图依次展示了由未旋转摄像头、顺时针旋转90度的摄像头、以及逆时针旋转90度的摄像头所拍摄的帧。箭头表示“真实向上”方向。

下图展示了由FPGA硬件实现的90度顺时针旋转。

输入格式
The only line of the input contains one integer x ( - 1018 ≤ x ≤ 1018) — camera angle in degrees. Positive value denotes clockwise camera rotation, negative — counter-clockwise.
输入仅包含一行,其中有一个整数 x(−1018≤x≤1018)——相机角度(单位:度)。正值表示顺时针旋转,负值表示逆时针旋转。
输出格式
Output one integer — the minimum required number of 90 degrees clockwise turns.
输出一个整数——所需的最小 90 度顺时针旋转次数。
输入输出样例
输入#1
60
输出#1
1
输入#2
-60
输出#2
3
说明/提示
When the camera is rotated 60 degrees counter-clockwise (the second example), an image from it is rotated 60 degrees clockwise. One 90 degrees clockwise turn of the image result in 150 degrees clockwise total rotation and deviation from "true up" for one turn is 150 degrees. Two 90 degrees clockwise turns of the image result in 240 degrees clockwise total rotation and deviation from "true up" for two turns is 120 degrees because 240 degrees clockwise equal to 120 degrees counter-clockwise. Three 90 degrees clockwise turns of the image result in 330 degrees clockwise total rotation and deviation from "true up" for three turns is 30 degrees because 330 degrees clockwise equal to 30 degrees counter-clockwise.
From 60, 150, 120 and 30 degrees deviations the smallest is 30, and it it achieved in three 90 degrees clockwise turns.
当相机逆时针旋转 60 度(第二个示例)时,其拍摄的图像将顺时针旋转 60 度。对图像进行一次 90 度顺时针旋转,总旋转角度为 150 度顺时针,相对于“正上方向”(true up)的偏差即为 150 度。对图像进行两次 90 度顺时针旋转,总旋转角度为 240 度顺时针,而相对于“正上方向”的偏差为 120 度,因为 240 度顺时针等价于 120 度逆时针。对图像进行三次 90 度顺时针旋转,总旋转角度为 330 度顺时针,而相对于“正上方向”的偏差为 30 度,因为 330 度顺时针等价于 30 度逆时针。
在 60、150、120 和 30 度这四个偏差值中,最小值为 30 度,且该最小值在进行三次 90 度顺时针旋转时达到。
输入解题思路,AI测评打分。不知道怎么写?