結果
問題 |
No.1509 Swap!!
|
ユーザー |
|
提出日時 | 2021-11-02 00:03:18 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 155 ms / 2,000 ms |
コード長 | 1,595 bytes |
コンパイル時間 | 14,911 ms |
コンパイル使用メモリ | 377,564 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-10 17:40:26 |
合計ジャッジ時間 | 18,068 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 |
ソースコード
use std::io::{Write, BufWriter}; // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } macro_rules! input_inner { ($next:expr) => {}; ($next:expr,) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ($(read_value!($next, $t)),*) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error")); } fn gcd(mut x: i64, mut y: i64) -> i64 { while y != 0 { let r = x % y; x = y; y = r; } x } // Tags: o1-math fn main() { let out = std::io::stdout(); let mut out = BufWriter::new(out.lock()); macro_rules! puts {($($format:tt)*) => (let _ = write!(out,$($format)*););} input! { t: usize, nab: [(i64, i64, i64); t], } for (n, a, b) in nab { if gcd(a, b) != 1 || a + b > n + 1 { puts!("NO\n"); continue; } puts!("YES\n"); } }