A Simple Task
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
Example
For n = 24, o = 3 and p = 3.
Task
Write a program which for each data set:
reads a positive integer n,
computes the odd integer o and the nonnegative integer p such that n = o2^p,
writes the result.
输入
Each data set consists of exactly one line containing exactly one integer n, 1 <= n <= 10^6.
输出
Line i, 1 <= i <= d, corresponds to the i-th input and should contain two integers o and p separated by a single space such that n = o2^p.
示例输入
1 24
示例输出
3 3
一个简单的任务
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
时间限制:1000MS内存限制:65536k有疑问点这里^ _ ^?
题目描述
题目描述
Given a positive integer n and the odd integer o and the nonnegative integer p such that n = o2^p.
给出一个正整数n和奇整数和非负整数p,n = O2 ^ P.
Example
的例子
For n = 24, o = 3 and p = 3.
对于n = 24,O = 3和P = 3。
Task
任务
Write a program which for each data set:
写一个程序,为每个数据集:
reads a positive integer n,
读入一个正整数n,
computes the odd integer o and the nonnegative integer p such that n = o2^p,
计算奇整数和非负整数p,n = O2 ^ P,
writes the result.
结果写入。
输入
输入
The first line of the input contains exactly one positive integer d equal to the number of data sets, 1 <= d <= 10. The data sets follow.
输入的第一行包含一个正整数d等于数据集的数目,1≤d≤10。数据集的后续。
Each data set consists of exactly one line containing exactly one integer n, 1 <= n <= 10^6.
每个数据集由一行包含一个整数N,1≤n≤10 ^ 6。
输出
输出
The output should consists of exactly d lines, one line for each data set.
输出应完全由D线,一条线为每个数据集。
Line i, 1 <= i <= d, corresponds to the i-th input and should contain two integers o and p separated by a single space such that n = o2^p.
我行,1<=我< = D,对应于第i输入应包含两个整数,O和P由一个单一的空间,N = O2分离^ P.
示例输入
示例输入
1
1
24示例输出
24示例输出
3 3
3 3
#include <stdio.h>
int main()
{
int i, n, k;
scanf("%d", &i);
while (i--){
scanf("%d", &n);
k = 0;
while (1){
if ((n&1) != 0) break;
n >>= 1;
k++;
}
printf("%d %d\n", n, k);
}
return 0;
}