結果
問題 |
No.312 置換処理
|
ユーザー |
|
提出日時 | 2025-05-31 11:09:18 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 632 bytes |
コンパイル時間 | 14,469 ms |
コンパイル使用メモリ | 404,100 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-05-31 11:09:35 |
合計ジャッジ時間 | 16,495 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 45 |
コンパイルメッセージ
warning: unused import: `std::collections::VecDeque` --> src/main.rs:9:5 | 9 | use std::collections::VecDeque; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
ソースコード
/* * Author: srtry * Created: 2025-05-31T10:22:10+09:00 * Coding: utf-8-unix */ use proconio::input; use std::io::{stdout,Write,BufWriter}; use std::collections::VecDeque; fn main() { input!{ n:usize } let out = stdout(); let mut out = BufWriter::new(out.lock()); // 3以上の約数のうち最小のものを計算すればいい let mut ans = n; if n%2==0 && n!=4{ ans = n/2; } for factor in 3..=(n as f64).sqrt() as usize { if n%factor==0 { ans = factor; break; } } write!(out, "{}", ans).unwrap(); }