結果
問題 |
No.983 Convolution
|
ユーザー |
![]() |
提出日時 | 2020-02-11 14:12:03 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 588 bytes |
コンパイル時間 | 11,659 ms |
コンパイル使用メモリ | 377,652 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-01 07:31:30 |
合計ジャッジ時間 | 13,128 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
コンパイルメッセージ
warning: unused variable: `n` --> src/main.rs:15:9 | 15 | let n: usize = it.next().unwrap().parse().unwrap(); | ^ help: if this is intentional, prefix it with an underscore: `_n` | = note: `#[warn(unused_variables)]` on by default
ソースコード
use std::io::Read; fn gcd(a: i64, b: i64) -> i64 { if b == 0 { a } else { gcd(b, a % b) } } fn run() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); let n: usize = it.next().unwrap().parse().unwrap(); let mut ans = 0; for s in it { let a: i64 = s.parse().unwrap(); if a > 0 { ans = gcd(ans, a * a); } } if ans == 0 { println!("-1"); } else { println!("{}", ans); } } fn main() { run(); }