結果

問題 No.887 Collatz
コンテスト
ユーザー ああ
提出日時 2026-10-14 13:28:07
言語 Rust
(1.99.0 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 2,000 ms
+ 157µs
コード長 324 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 10,880 ms
コンパイル使用メモリ 179,536 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-10-14 13:28:21
合計ジャッジ時間 5,577 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable does not need to be mutable
 --> src/main.rs:7:9
  |
7 |     let mut num=0;
  |         ----^^^
  |         |
  |         help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` (part of `#[warn(unused)]`) on by default

warning: unused variable: `num`
 --> src/main.rs:7:9
  |
7 |     let mut num=0;
  |         ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_num`
  |
  = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

ソースコード

diff #
raw source code

use proconio::input;
fn main(){
    input!{
        mut x:usize,
    }
    let mut ans=x;
    let mut num=0;
    let mut c=0;
    while x>1{
        if x%2==0{
            x/=2;
        } else {
            x*=3;x+=1;
        }
        c+=1;
        if ans<x{
            ans=x;
        }
    }
    print!("{}\n{}",c,ans);
}
0