列表

详情


NC223808. RiseofShadows

描述

Azeroth is a world full of fantasy. In Azeroth, there are hours in a day and minutes in an hour.

You found a clock made from Azeroth. The clock has two hands --- the hour hand and the minute hand. The two hands point to the same direction at the start of a day. Either hand rotates at a constant speed. The hour hand goes around a full circle in hours and the minute hand goes around a full circle in minutes. Surprisingly, it is night in Azeroth if and only if the angle between the two hands is less than or equal to .
Now you're wondering, given , how many integral moments (i.e., integer minutes since the start of the day) are there, such that the angle between the two hands is less than or equal to .

输入描述

The only line of the input contains three integers   and  , representing the number of hours in a day and the number of minutes in an hour, and the limit of the angle in radians, respectively.

输出描述

Print an integer representing the answer.

示例1

输入:

5 5 4

输出:

9

示例2

输入:

3 5 1

输出:

3

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++ 解法, 执行用时: 4ms, 内存消耗: 560K, 提交时间: 2022-04-04 19:46:51

#include<bits/stdc++.h>
typedef long long ll;ll H,M,A;
int main(){std::cin>>H>>M>>A;ll d=(std::__gcd(H-1,H*M));std::cout<<std::min(H*M,d*(A/d*2+1));}

Python3 解法, 执行用时: 71ms, 内存消耗: 7128K, 提交时间: 2021-11-18 17:15:36

from math import gcd
h, m, a = map(int, input().split())
d = gcd(h-1, m*h)
print(h*m if a * 2 == h * m else d * (a // d * 2 + 1))

上一题