水题 A Simple Task
来源:互联网 发布:java queue 编辑:程序博客网 时间:2024/05/16 06:16
A Simple Task
Time Limit : 2000/1000ms(Java/Other) MemoryLimit : 65536/32768K (Java/Other)
Total Submission(s) :18 AcceptedSubmission(s) : 11
Font: Times NewRoman | Verdana | Georgia
Font Size: ← →
Problem Description
Given a positive integer n and the odd integer o and thenonnegative 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 thatn = o2^p,
writes the result.
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 thatn = o2^p,
writes the result.
Input
The first line of the input contains exactly one positive integer dequal to the number of data sets, 1 <= d<= 10. The data sets follow.
Each data set consists of exactly one line containing exactly oneinteger n, 1 <= n <=10^6.
Each data set consists of exactly one line containing exactly oneinteger n, 1 <= n <=10^6.
Output
The output should consists of exactly d lines, one line for eachdata set.
Line i, 1 <= i <= d, corresponds tothe i-th input and should contain two integers o and p separated bya single space such that n = o2^p.
Line i, 1 <= i <= d, corresponds tothe i-th input and should contain two integers o and p separated bya single space such that n = o2^p.
Sample Input
1
24
Sample Output
3 3
#include<stdio.h>
int a[100];
int j;
void xx()
{
int i;
a[0]=1;
i=0;
while(a[i]<1000000)
{
++i;
a[i]=2*a[i-1];
}
j=i;
}
int main()
{
int n,m;
int i;
xx();
scanf("%d",&n);
while(n--)
{
scanf("%d",&m);
if(m%2) printf("%d 0\n",m);
else
{
for(i=1;i<j;i++)
{
if(m%a[i]==0&&m/a[i]%2!=0)
{
printf("%d %d\n",m/a[i],i);
break;
}
}
}
}
return 0;
}
- 水题 A Simple Task
- HDU 1339 A Simple Task
- Writing a Simple …
- A simple puzzle game
- A Simple Math Problem
- poj 3468 A Simple Problem with I…
- poj 3468 A Simple Problem with I…
- poj 3468 A Simple Problem with I…
- poj 3468 A Simple…
- WDA: A simple tes…
- 线段树 hdu3468 A Simple Problem…
- WDA: A Simple Test of ALV
- HDOJ 2101 A + B Problem Too
- hdu 1497 Simple Library Manageme…
- hdu 1000 A + B Problem
- fzu 1759 A^B % C
- #define A (* (volatile unsigned …
- HDOJ 2075 A|B?
- 运用位运算会比较简单 Binary Numb…
- 最小生成树 Jungle Roads
- 寒冰王座
- 水题 Parity
- 架构
- 水题 A Simple Task
- 有关栈的代码模板
- 栈的练习 Train Problem I
- 循环队列 约瑟夫问题
- hdu 1692 Destroy the Well of Lif…
- hdu 1157 Who's in the Middle(poj…
- 一个不错的资料网站 维基百科
- poj 2299 Ultra-QuickSort 归并排…
- poj 1804 (归并排序求逆序数)Bra…