水题 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.

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.

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.

Sample Input

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;
}
原创粉丝点击