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. OpenCV(6)-腐蚀和膨胀

    腐蚀和膨胀属于形态学操作. 腐蚀和膨胀 腐蚀是指:将卷积核B滑过图像A,找出卷积核区域内最小像素值作为锚点像素值.这一操作可以扩大低像素值区域. 膨胀是指:将卷积核B滑过图像A,找出卷积核区域内最大像 ...

  2. ASP.NET 优化 check list

    看到一个蛮有意思的网站,里面有针对asp.net方方面面优化的罗列: 点击打开链接http://webdevchecklist.com/asp.net/performance/ 点击打开链接http: ...

  3. mysql复制表数据或表结构到新表中

    MySQL复制表数据到新表的几个步骤. 1.MySQL复制表结构及数据到新表 CREATE TABLE new_table SELECT * FROM old_table; 2.只复制表结构到新表 C ...

  4. 一个开源的可视化的jQuery工作流插件

    特点 1.跨浏览器,可兼容IE7--IE11, FireFox, Chrome, Opera等几大内核的浏览器,且不需要浏览器再加装任何控件. (IE7-IE8时,使用VML:IE9以上,FF,OPE ...

  5. 包管理器Bower使用手册之一

    包管理器Bower使用手册之一 作者:chszs,转载需注明.博客主页:http://blog.csdn.net/chszs 一.Bower介绍 Bower是一个适合Web应用的包管理器,它擅长前端的 ...

  6. Lighttpd日志打印格式

    检查lighttpd打印的日志时,有些字段意义模糊,就找了个对照说明,备份一下 原文地址:http://redmine.lighttpd.net/projects/1/wiki/Docs_ModAcc ...

  7. MySql 在大数量的统计中具体的使用技巧

    一.CASE WHEN THEN ELSE END 使用用法. 在用sql语句统计某字段的某种状态的出现的次数,可以考虑用到 CASE WHEN THEN ELSE END 使用用法.当数据量过于庞大 ...

  8. php接收二进制数据流转换成图片

    <?php /** * 图片类 * @author Haroldphp@163.com * @version 1.0 * PHP默认只识别application/x-www.form-urlen ...

  9. IOS多线程之NSThread

    参考:http://blog.csdn.net/totogo2010/article/details/8010231 1 简介 NSThread: 优点:NSThread 比其他两个轻量级 缺点:需要 ...

  10. QQ宠物吹泡泡游戏小助手 VC++6.0代码分析

    最近玩QQ宠物,他总是心情低落,让我很不爽,让他玩耍吧,还得自己点鼠标,所以想偷个懒,试试能不能编个程序让电脑帮我做这个事情. 要干这件事就得先找一个游戏开刀,刚开始我找的是弹力球游戏,不就是点鼠标么 ...