A13413 | Candies
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Recently Vova found $n$ candy wrappers. He remembers that he bought $x$ candies during the first day, $2x$ candies during the second day, $4x$ candies during the third day, $\dots$ , $2^{k-1} x$ candies during the $k$ -th day. But there is an issue: Vova remembers neither $x$ nor $k$ but he is sure that $x$ and $k$ are positive integers and $k > 1$ .
Vova will be satisfied if you tell him any positive integer $x$ so there is an integer $k>1$ that $x + 2x + 4x + \dots + 2^{k-1} x = n$ . It is guaranteed that at least one solution exists. Note that $k > 1$ .
You have to answer $t$ independent test cases.
Vova will be satisfied if you tell him any positive integer $x$ so there is an integer $k>1$ that $x + 2x + 4x + \dots + 2^{k-1} x = n$ . It is guaranteed that at least one solution exists. Note that $k > 1$ .
You have to answer $t$ independent test cases.
输入格式
The first line of the input contains one integer $t$ ( $1 \le t \le 10^4$ ) — the number of test cases. Then $t$ test cases follow.
The only line of the test case contains one integer $n$ ( $3 \le n \le 10^9$ ) — the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $x$ and integer $k>1$ that $x + 2x + 4x + \dots + 2^{k-1} x = n$ .
The only line of the test case contains one integer $n$ ( $3 \le n \le 10^9$ ) — the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $x$ and integer $k>1$ that $x + 2x + 4x + \dots + 2^{k-1} x = n$ .
输出格式
Print one integer — any positive integer value of $x$ so there is an integer $k>1$ that $x+2x+4x+⋯+2^{k-1}x=n$.
输入输出样例
输入 #1
7 3 6 7 21 28 999999999 999999984
输出 #1
1 2 1 7 4 333333333 333333328
In the first test case of the example, one of the possible answers is $x=1, k=2$ . Then $1 \cdot 1 + 2 \cdot 1$ equals $n=3$ .
In the second test case of the example, one of the possible answers is $x=2, k=2$ . Then $1 \cdot 2 + 2 \cdot 2$ equals $n=6$ .
In the third test case of the example, one of the possible answers is $x=1, k=3$ . Then $1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$ equals $n=7$ .
In the fourth test case of the example, one of the possible answers is $x=7, k=2$ . Then $1 \cdot 7 + 2 \cdot 7$ equals $n=21$ .
In the fifth test case of the example, one of the possible answers is $x=4, k=3$ . Then $1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$ equals $n=28$ .
In the second test case of the example, one of the possible answers is $x=2, k=2$ . Then $1 \cdot 2 + 2 \cdot 2$ equals $n=6$ .
In the third test case of the example, one of the possible answers is $x=1, k=3$ . Then $1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$ equals $n=7$ .
In the fourth test case of the example, one of the possible answers is $x=7, k=2$ . Then $1 \cdot 7 + 2 \cdot 7$ equals $n=21$ .
In the fifth test case of the example, one of the possible answers is $x=4, k=3$ . Then $1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$ equals $n=28$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted