結果
| 問題 | No.3631 Collatz conjecture |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-21 21:28:19 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,676 bytes |
| 記録 | |
| コンパイル時間 | 252 ms |
| コンパイル使用メモリ | 96,236 KB |
| 実行使用メモリ | 79,360 KB |
| 最終ジャッジ日時 | 2026-08-21 21:28:36 |
| 合計ジャッジ時間 | 5,531 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 52 WA * 1 |
ソースコード
# coding: utf-8
# AtCoder Competition Template v2.1 SHORT (PyPy 7.3.20 / Python 3.11) ※yukicoder用に編集した物
# ↑ https://github.com/Rino-program/atcoder/blob/main/contests/.template/main.py
# oj test -c 'C:\Rino-program\AtCoder\.venv-pypy311\Scripts\python.exe maina.py' -d input/a
import sys
import math
# ===== 入出力ヘルパ =====
def input() -> str:
return sys.stdin.readline().rstrip()
def INT() -> int:
return int(input())
def MAP():
return map(int, input().split())
def LIST() -> list[int]:
return list(MAP())
def TUPLE() -> tuple[int, ...]:
return tuple(MAP())
def TUPLES(n: int) -> list[tuple[int, ...]]:
return [TUPLE() for _ in range(n)]
# ===== 定数 =====
INF = 10 ** 18
# ===== 関数短縮 =====
pr = print
en = enumerate
# ===== よく使う出力関数 =====
def Yes(): print("Yes")
def No(): print("No")
def yn(cond: bool) -> None:
"""条件に応じてYes/No出力"""
print("Yes" if cond else "No")
# ===== デバッグ =====
def debug(*args, **kwargs) -> None:
"""デバッグ出力(標準エラー)"""
print("[DEBUG]", *args, **kwargs, file=sys.stderr)
# ==============================================
# =================== main =====================
# ==============================================
def main() -> None:
# ここに解答を書く
# 答えは意外と小さそう
N = INT()
ans = 0
while N != 1:
ans += 1
if N % 2:
N *= 3
N += 1
else:
N //= 2
if ans > 10**7:
pr("infinity")
return
pr(ans)
if __name__ == "__main__":
main()