結果

問題 No.3020 ユークリッドの互除法・改
ユーザー ArcAki
提出日時 2025-02-14 22:05:49
言語 Rust
(1.83.0 + proconio)
結果
RE  
実行時間 -
コード長 604 bytes
コンパイル時間 11,736 ms
コンパイル使用メモリ 407,460 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-14 22:09:01
合計ジャッジ時間 12,899 ms
ジャッジサーバーID
(参考情報)
judge6 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 5 RE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

warning: variable `pro` is assigned to, but never used
  --> src/main.rs:28:13
   |
28 |     let mut pro = 1;
   |             ^^^
   |
   = note: consider using `_pro` instead
   = note: `#[warn(unused_variables)]` on by default

ソースコード

diff #

#[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!{
        mut a: [i64; 4],
	}
    let mut g = 0;
    let mut pro = 1;
    for &v in &a{
        g = gcd(g, v);
        pro *= v;
    }
    println!("{} {}", g, (a[0]*a[3]-a[1]*a[2]).abs()/g);
}
0