1. 程式人生 > >zcmu-1141: 鬆哥的困惑VII(披著dp外衣的簡單題)

zcmu-1141: 鬆哥的困惑VII(披著dp外衣的簡單題)

1141: 鬆哥的困惑VII

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 285  Solved: 121
[Submit][Status][Web Board]

Description

 

 

有一天dp小王子偷偷摸摸找到鬆哥問他:已知n=o*2^p,已知n你能求出o和p嘛?鬆哥笑了笑告訴他,明天再告訴你。其實鬆哥並不知道答案,所以他想讓你告訴他答案,然後他在把答案告訴dp小王子,鬆哥發現有可以有很多組o和p,所以決定只告訴他p最大的一組,O(∩_∩)O哈哈~

 

Input

 

 

多組測試資料.

每組測試資料有一個整數n.

n在int範圍內.

 

Output

 

 

對於每組測試資料,輸出滿足條件的o和p,p儘可能大

 

Sample Input

24

Sample Output

3 3



 

就很簡單,把2全部摘出來就行,最讓我傷心的就是!!!這裡要求了多組輸入...我剛開始沒注意,wa了一發 哭了... 

#include<stdio.h>
#include<stdlib.h>
#include <string.h>

int  main()
{
    int n,cnt;
    while(scanf("%d",&n) != EOF)
    {
        cnt = 0;
        while(1)
        {
            if(n%2 != 0)
                break;
            else
            {
                n /= 2;
                cnt++;
            }
        }
        printf("%d %d\n",n,cnt);
    }
   
    return 0;
}