結果

問題 No.1236 長針と短針
ユーザー どらら
提出日時 2020-09-26 01:55:18
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 868 bytes
コンパイル時間 19,863 ms
コンパイル使用メモリ 378,088 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 10:11:55
合計ジャッジ時間 20,227 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;
use std::str::FromStr;

fn calc(a: i32, b: i32) -> i32 {
    let a = if a >= 12 { a - 12 } else { a };
    if a == 0 && b == 0 {
        return 0;
    }

    let mut x = (a * 60 + b) * 60;
    let mut y = 720 * b;

    let mut ret = 0;
    loop {
        if y < x && y + 12 == x + 1 {
            ret += 1;
            break;
        } else if y < x && y + 12 >= x + 1 {
            break;
        }
        x += 1;
        y += 12;

        ret += 1;
        if x >= 360 * 120 {
            x -= 360 * 120;
        }
        if y >= 360 * 120 {
            y -= 360 * 120;
        }
    }

    ret
}

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|x| i32::from_str(x).unwrap());
    let (a, b) = (itr.next().unwrap(), itr.next().unwrap());

    println!("{}", calc(a, b));
}
0