B. 慕雪少年的函数变换之旅

    传统题 1000ms 256MiB

慕雪少年的函数变换之旅

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Description

Muxue the youth has defined an interesting mathematical function f(x):

  • If x is even, the function returns x/2
  • If x is odd, the function returns 3x+1

Now, Muxue wants to study the iterative properties of this function. Given an initial value n and a non-negative integer k, please calculate the result after consecutively calling function f on n for k times.

Note: When k=0, the result is n itself.

Input Format

Two integers n and k, separated by a space (1 ≤ n ≤ 1000, 0 ≤ k ≤ 1000)

Output Format

An integer, representing the result after k function calls

Sample Input and Output #1

Input #1

5 3

Output #1

4

Sample Input and Output #2

Input #2

10 0

Output #2

10

Explanation/Notes

Explanation for Sample 1: f(5)=16, f(16)=8, f(8)=4, so the result after 3 calls is 4.

This problem uses Subtask bundled testing

【XJS-C5-Div5】XJSOI 春节大月赛 Round 3 & 勰码可达鸭合作赛 Round 1

未参加
状态
已结束
规则
IOI
题目
5
开始于
2026-2-7 0:00
结束于
2026-2-14 0:00
持续时间
2 小时
主持人
参赛人数
10