(HDU)1339 -- A Simple Task(简单任务)

题目链接:http://vjudge.net/problem/HDU-1339

给你一个数N,找出N=o*(2^p)表达形式的o和p。

分奇数偶数分析一波就得出规律了。

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cmath>
 4 #include <iostream>
 5 #include <algorithm>
 6 #include <string>
 7 #include <cstdlib>
 8 
 9 using namespace std;
10 
11 int main()
12 {
13     int t,m,n,k,s;
14     scanf("%d",&t);
15     while(t--)
16     {
17         scanf("%d",&n);
18         k=0;m=1;s=n;
19         while(n%2==0)
20         {
21             n/=2;
22             k++;
23             m=m*2;
24         }
25         printf("%d %d
",s/m,k);
26     }
27     return 0;
28 }
原文地址:https://www.cnblogs.com/ACDoge/p/6137772.html