山东理工大学ACM平台题答案关于C语言 1063 A Simple Task
2013-12-15 16:03
225 查看
A Simple Task
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
Given a positive integer n and the odd integer o and the nonnegative integer p such that n = o2^p.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.
输入
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.Each data set consists of exactly one line containing exactly one integer n, 1 <= n <= 10^6.
输出
The output should consists of exactly d lines, one line for each data set.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.示例输入示例输入1124示例输出24示例输出3 33 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;
}
相关文章推荐
- 山东理工大学ACM平台题答案关于C语言 1231 绝对值排序
- 山东理工大学ACM平台题答案关于C语言 1137 C/C++经典程序训练7---求某个范围内的所有素数
- 山东理工大学ACM平台题答案关于C语言 1164 C语言实验——矩阵转置
- 山东理工大学ACM平台题答案关于C语言 1226 支配值数目
- 山东理工大学ACM平台题答案关于C语言 1176 C语言实验——删除指定字符
- 山东理工大学ACM平台题答案关于C语言 1228 两数组最短距离
- 山东理工大学ACM平台题答案关于C语言 1162 C语言实验——保留字母
- 山东理工大学ACM平台题答案关于C语言 1252 进制转换
- 山东理工大学ACM平台题答案关于C语言 1012 A+B for Input-Output Practice (III)
- 山东理工大学ACM平台题答案关于C语言 2098 识别浮点常量问题
- 山东理工大学ACM平台题答案关于C语言 1295 螺旋方阵
- 山东理工大学ACM平台题答案关于C语言 1181 C语言实验——最小公倍数和最大公约数
- 山东理工大学ACM平台题答案关于C语言 1240 多项式求和
- 山东理工大学ACM平台题答案关于C语言 1015 A+B for Input-Output Practice (VI)
- 山东理工大学ACM平台题答案关于C语言 1194 C语言实验——余弦
- 山东理工大学ACM平台题答案关于C语言 1543 Egypt
- 山东理工大学ACM平台题答案关于C语言 1580 闰年
- 山东理工大学ACM平台题答案关于C语言 1580 闰年
- 山东理工大学ACM平台题答案关于C语言 1255 小明A+B
- 山东理工大学ACM平台题答案关于C语言 1227 等值数目