编程介的小学生 2019-12-30 18:01 采纳率: 0.2%
浏览 72

Strange Clock 时钟问题

Problem Description
There is a strange clock, without any number written. Can you tell me what time it is now, based on the angle of the hour hand?

When the hour hand points right (0 degree), it is 3 o'clock. When it points to 80 degrees, it’s between 0 o'clock and 1 o'clock. Note that there is no 12 o'clock. You should always write 0 o'clock instead.

Input
There are at most 10 test cases. Each case contains a single integer a (0 <= a < 360), the angle of the hour hand. The input ends with a = -1.

Output
For each test case, print the current time, in one of the following format:

  • Exactly x o'clock
  • Between x o'clock and y o'clock Note that, in the second format, x o'clock should be exactly one hour before y o'clock, So you cannot write something like “Between 3 o'clock and 2 o'clock”.

Sample Input
90
245
-1

Sample Output
Exactly 0 o'clock
Between 6 o'clock and 7 o'clock

  • 写回答

1条回答 默认 最新

  • 你知我知皆知 2024-07-27 15:57
    关注

    以下回答参考 皆我百晓生券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。

    # 读取数据
    data <- readLines()
    
    for(i in 1:length(data)) {
        data[i] <- as.numeric(gsub("[^0-9]", "", data[i]))
    }
    
    # 处理输入
    cases <- lapply(1:length(data), function(x) {
        a <- data[x]
        if(a == -1) return(-1)
        if(a > 180) {
            a <- a %-% 180
            if(a >= 360) a <- a - 360
        }
        c("Between", "Exactly")[a %% 360 == 0]
    })
    
    # 输出结果
    results <- lapply(cases, function(x) paste("Between", x, sep=""))
    print(results)
    
    评论

报告相同问题?

悬赏问题

  • ¥20 看图片)删除这个自动化录屏脚本就一直报错找不到脚本文件,如何解决?(相关搜索:bat文件)
  • ¥750 关于一道数论方面的问题,求解答!(关键词-数学方法)
  • ¥200 csgo2的viewmatrix值是否还有别的获取方式
  • ¥15 Stable Diffusion,用Ebsynth utility在视频选帧图重绘,第一步报错,蒙版和帧图没法生成,怎么处理啊
  • ¥15 请把下列每一行代码完整地读懂并注释出来
  • ¥15 pycharm运行main文件,显示没有conda环境
  • ¥15 寻找公式识别开发,自动识别整页文档、图像公式的软件
  • ¥15 为什么eclipse不能再下载了?
  • ¥15 编辑cmake lists 明明写了project项目名,但是还是报错怎么回事
  • ¥15 关于#计算机视觉#的问题:求一份高质量桥梁多病害数据集