http://acm.hdu.edu.cn/showproblem.php?pid=1339

正常做法超时,要有点小技巧存在。

A Simple Task

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3372    Accepted Submission(s): 1837

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
 
Source
 
Recommend
Ignatius.L

#include<stdio.h>
int main()
{
long int d,k,n;
scanf("%ld",&d);
while(d--)
{
scanf("%ld",&n);
k=;
while(n%==)
{ k++;
n=n/;
}
printf("%ld %ld\n",n,k);
}
return ;
}

HDU-1339 A Simple Task的更多相关文章

  1. HDOJ 1339 A Simple Task(简单数学题,暴力)

    Problem Description Given a positive integer n and the odd integer o and the nonnegative integer p s ...

  2. HDU 5795 A Simple Nim(简单Nim)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  3. 计数排序 + 线段树优化 --- Codeforces 558E : A Simple Task

    E. A Simple Task Problem's Link: http://codeforces.com/problemset/problem/558/E Mean: 给定一个字符串,有q次操作, ...

  4. HDU 5794 - A Simple Chess

    HDU 5794 - A Simple Chess题意: 马(象棋)初始位置在(1,1), 现在要走到(n,m), 问有几种走法 棋盘上有r个障碍物, 该位置不能走, 并规定只能走右下方 数据范围: ...

  5. A Simple Task

    A Simple Task Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  6. HDU 4974 A simple water problem(贪心)

    HDU 4974 A simple water problem pid=4974" target="_blank" style="">题目链接 ...

  7. hdu 4972 A simple dynamic programming problem(高效)

    pid=4972" target="_blank" style="">题目链接:hdu 4972 A simple dynamic progra ...

  8. Codeforces 558E A Simple Task (计数排序&&线段树优化)

    题目链接:http://codeforces.com/contest/558/problem/E E. A Simple Task time limit per test5 seconds memor ...

  9. Codeforces Round #312 (Div. 2) E. A Simple Task 线段树

    E. A Simple Task 题目连接: http://www.codeforces.com/contest/558/problem/E Description This task is very ...

随机推荐

  1. c语言全局变量与局部变量(当变量重名时)的使用情况

    在c语言中,变量有全局变量和局部变量之分,这一点和很多高级语言类似,如c#,java等.不过与c#,java中的局部变量如在全局变量作用域内则不允许与全局变量名相同,而c语言是允许这样做的.这样的做法 ...

  2. DataTable.ImportRow()与DataTable.Rows.Add()的区别

    今天写代码的时候用到ImportRow()向DataTable中添加记录,代码如下: DataTable dt = datatable;DataRow dr = dt.NewRow();dr[&quo ...

  3. js实现一个砖头在页面拖拉效果

    用js实现一个砖头在页面,但鼠标点击拖动时,砖头在页面上形成拖拉效果: 刚开始时: 鼠标点击拖动后: 实现代码: <html>   <head>       <meta ...

  4. PAT_1002 写出这个数

    宝宝不开心了.自从回家开始百练就上不去POJ也上不去,今天突然HDU也上不去了,PAT25分的题目都快更新完了.我就按顺序往下面更新了.回学校之后题目质量能高出不少= =. 问题描述: 读入一个自然数 ...

  5. linux一部分常用的命令

    如今的web项目,一般在windows下开发,然后部署在linux上.搜索了一下原因,大概是说,linux免费,此外,linux长时间运行都没有问题,可以达到1到2年不停机.因此,需要学习一些常用的l ...

  6. Ubuntu不卸载ibus前提下安装搜狗输入法

    第一步 在命令行中输入以下行命令安装fictx框架 sudo apt-get install fcitx fcitx-config-gtk im-switch 第二步 去 http://pinyin. ...

  7. 【原创】Linux编译内核

    Linux 编译内核 大致分这几个步骤 1.准备编译工具.内核文件 2.开始编译 3.将编译好的新内核install进系统 4.查看是否成功.   一.准备好必备的库和内核文件   1.添加必备的编译 ...

  8. zzuli oj 1165 实数的小数部分(指针专题)

    Description 读入一个实数,输出该实数的小数部分,小数部分若多余的末尾0,请去掉.如输入111111.12345678912345678900  则输出0.12345678912345678 ...

  9. 转载:Source Insight查看ARM汇编源程序 && 高亮显示程序 && Source Insight打开project窗口出错

    (1)Source Insight查看ARM汇编源程序.做ARM嵌入式开发时,有时得整汇编代码,但在SIS里建立PROJECT并ADD TREE的时候,根据默认设置并不会把该TREE里面所有汇编文件都 ...

  10. bootstrap框架应用

    ---------------------------------------------------------------bootstrap---------------------------- ...