首页 > 其他分享 >杭电1339

杭电1339

时间:2023-02-06 21:04:23浏览次数:51  
标签:set 1339 int positive exactly 杭电 integer data


A Simple Task

Problem Description
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.

Input
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.

Output
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.

Sample Input
1
24

Sample Output
3 3

题意:n = o*2^p;成立的o,p奇数

# include <iostream>
# include <cstdio>

int main(){

int n,m;

while(scanf("%d",&n)!=EOF){

while(n--){
scanf("%d",&m);
int cnt = 0;
while(m%2==0){
cnt++;
m = m/2;
}

printf("%d %d\n",m,cnt);
}

}



return 0;
}


标签:set,1339,int,positive,exactly,杭电,integer,data
From: https://blog.51cto.com/u_15955675/6040502

相关文章

  • 杭电1335-任意进制的转换
    BasicallySpeaking​​http://acm.hdu.edu.cn/showproblem.php?pid=1335​​ProblemDescriptionTheReallyNeatoCalculatorCompany,Inc.hasrecentlyhiredyourt......
  • 杭电1407--暴力与优化
    测试你是否和LTC水平一样高ProblemDescription大家提到LTC都佩服的不行,不过,如果竞赛只有这一个题目,我敢保证你和他绝对在一个水平线上!你的任务是:计算方程x^2+y^2+z^2......
  • 杭电1114--完全背包
    Piggy-BankProblemDescriptionBeforeACMcandoanything,abudgetmustbepreparedandthenecessaryfinancialsupportobtained.Themainincomeforthisacti......
  • 杭电1266--数的倒叙
    ReverseNumberProblemDescriptionWelcometo2006’4computercollegeprogrammingcontest!Specially,Igivemybestregardstoallfreshmen!Youarethefuture......
  • 杭电1282-回文
    回文数猜想ProblemDescription一个正整数,如果从左向右读(称之为正序数)和从右向左读(称之为倒序数)是一样的,这样的数就叫回文数。任取一个正整数,如果不是回文数,将该数与他的......
  • 杭电2602---01背包
    骨收集器​​http://acm.hdu.edu.cn/showproblem.php?pid=2602​​问题描述许多年前,在泰迪的家乡有一个叫“拾骨者”的人。这个人喜欢收集不同的骨头,比如狗,牛,他还去了坟......
  • 杭电1248-背包
    院大学生程序设计竞赛(新生为主)寒冰王座TimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):13570AcceptedSubm......
  • 杭电1201
    18岁生日ProblemDescriptionGardon的18岁生日就要到了,他当然很开心,可是他突然想到一个问题,是不是每个人从出生开始,到达18岁生日时所经过的天数都是一样的呢?似乎并不全都......
  • 杭电1202--学分
    ThecalculationofGPATimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):24013AcceptedSubmission(s):5610P......
  • 杭电1205--吃糖
    吃糖果ProblemDescriptionHOHO,终于从Speakless手上赢走了所有的糖果,是Gardon吃糖果时有个特殊的癖好,就是不喜欢将一样的糖果放在一起吃,喜欢先吃一种,下一次吃另一种,这样;可......