結果
| 問題 | No.3631 Collatz conjecture |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-08-24 01:36:00 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 716 bytes |
| 記録 | |
| コンパイル時間 | 715 ms |
| コンパイル使用メモリ | 184,092 KB |
| 実行使用メモリ | 9,732 KB |
| 最終ジャッジ日時 | 2026-08-24 01:36:04 |
| 合計ジャッジ時間 | 3,213 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 52 WA * 1 |
ソースコード
#![allow(non_snake_case, unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
use proconio::{input, marker::Usize1, marker::Chars};
use itertools::Itertools;
#[allow(unused_macros)]
macro_rules! d {
( $( $x:expr ),* $(,)? ) => {
eprintln!(
concat!( $( stringify!($x), "={:?} " ),* ),
$( $x ),*
);
};
}
#[allow(dead_code)]
fn yn(b: bool) -> &'static str {
if b { "Yes" } else { "No" }
}
fn collatz(n: i64) -> i64 {
if n == 1 {
0
} else if n % 2 == 0 {
collatz(n/2) + 1
} else {
collatz(3*n+1) + 1
}
}
fn main() {
input! {
N: i64,
}
let ans = collatz(N);
println!("{}", ans);
}
norioc