NC223808. RiseofShadows
描述
输入描述
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))