经典简约
清爽简洁,回归本真
液态水晶
毛玻璃+霓虹光带
赛博朋克
霓虹故障艺术风
🚫
违规操作检测
禁止使用右键菜单
⚠️ 此操作已被系统记录
1

Card Game

📝 题解 🔵 仅限 C++
题目描述
<p><span style="font-size: large;"><span style="font-family: Arial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Joe is playing a card game. There is a pile of cards numbered 1, 2, ... n from top to bottom. Every time Joe throws away the top card and puts the second card to the bottom, until there is only one card. Can you tell Joe the number of the last card?<br /> </span></span></p>
输入格式
<p><span style="font-size: large;"><span style="font-family: Arial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; There are multiple test cases (no more than 1000). Each test case contains only one integer n (1 &lt;= n &lt;= 10^6), the number of cards.<br /> </span></span></p>
输出格式
<p><span style="font-size: large;"><span style="font-family: Arial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; There is only one line for each test case, containing the last card's number.<br /> </span></span></p>
样例
样例输入 1
3 6 10
样例输出 1
2 4 4
提交代码
请先登录后提交

🤖 AI 解题助手

DeepSeek
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这道题,可以帮你分析思路、提供代码示例。
⚠️ 请先登录后使用