XiaoHuang's Space
XiaoHuang's Space
XiaoHuang
May the force be with you.
「CF80B」Depression
Posted: Mar 03, 2020
This article was last modified days ago. The content of this post may be outdated!

Portal

Portal1: Codeforces

Portal2: Luogu

Solution

首先我们可以确定分针的偏转角度为$m \times 6$(它不受时针影响)。

时针的话可以先算出自己因整小时影响的偏转角度为$n \times 30$,然后再加上分针的影响为$m \times 0.5$,即偏转角度为$n \times 30 + m \times 0.5$。

当时间超过半天(12:00)时,要把小时数减去$12$(也就是时针已经转了一圈,角度从$0$开始)。

输出的时候注意一下就好了。

Code

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>

using namespace std;

int n, m;
int main() {
    scanf("%d:%d", &n, &m);
    if (n >= 12) n -= 12;
    double ans1 = n * 30 + m * 0.5;//计算时针偏转角度
    int ans2 = m * 6;//计算分针偏转角度
    if ((int)ans1 == ans1) printf("%.0lf %d\n", ans1, ans2); else printf("%.1lf %d\n", ans1, ans2);//注意输出
    return 0;
}
Article License: CC BY-NC-ND 4.0
Article Author: XiaoHuang
  1. 1. Portal
  2. 2. Solution
  3. 3. Code
Newer Post
「Luogu P6069」[MdOI2020] Group
Older Post
「数学」Menelaus定理与Ceva定理
Buy me a beer?
-->
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×