結果
問題 | No.3020 ユークリッドの互除法・改 |
ユーザー |
|
提出日時 | 2025-02-14 22:13:04 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 654 bytes |
コンパイル時間 | 12,957 ms |
コンパイル使用メモリ | 402,344 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-14 22:14:13 |
合計ジャッジ時間 | 12,108 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
warning: unused imports: `fastout` and `marker::Chars` --> src/main.rs:7:23 | 7 | use proconio::{input, fastout, marker::Chars}; | ^^^^^^^ ^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
ソースコード
#[allow(unused_imports)]use std::{collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap},io::{read_to_string, stdin, Write, stdout},};use proconio::{input, fastout, marker::Chars};pub fn modulo(x: i64, y: i64)->i64{(x%y+y)%y}pub fn gcd(a: i64, b: i64)->i64{if b==0{a} else {gcd(b, modulo(a, b))}}//#[fastout]fn main(){input!{a: [i64; 4],}let mut g = 0;let d = (a[0]*a[3]-a[1]*a[2]).abs();for &v in &a{g = gcd(g, v);}g = g.abs();if g==0{println!("0 0");} else {println!("{} {}", g, d/g);}}