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. 使用AFNetworking进行图片上传

    转载自:http://blog.csdn.net/a645258072/article/details/51728806 项目中,我们经常会用到上传图片的功能,而目前的上传图片分为两种(我只知道两种, ...

  2. 12_复杂查询01_Mapper代理实现

    [工程截图] [代码实现] [user.java] package com.Higgin.Mybatis.po; import java.util.Date; public class User { ...

  3. Codevs 1191 数轴染色

    1191 数轴染色 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 在一条数轴上有N个点,分别是1-N.一开始所有的点都被染成黑色. ...

  4. 学习笔记---C++析构函数心得

    1.动态分配的对象的析构函数 class man{ public: man(){ cout<<"man begin"<<endl; }; ~man(){ c ...

  5. 模板:优先队列(priority_queue)

    #include <iostream> #include <cstdio> #include <queue> #include <vector> usi ...

  6. swift基本语法

    swift种语法着实怪异,实质干的事情还是一样的,一下将对此语法做简单介绍: 1.swift语法种已经剔除“:”这个结束符号,下面将演示入门操作的hello world import Foundati ...

  7. 『奇葩问题集锦』Zepto 页面唤醒拨号功能点透

    不废话直接上代码: HTML: <a class="js-tel tel" data-tel="1312414"></a> JS: // ...

  8. 【python】【转】if else 和 elif

    else和elif语句也可以叫做子句,因为它们不能独立使用,两者都是出现在if.for.while语句内部的.else子句可以增加一种选择:而elif子句则是需要检查更多条件时会被使用,与if和els ...

  9. MYSQL ERROR 1130: Host is not allowed to connect to this MySQL server

    今天安装MYSQL遇到MYSQL ERROR 1130: Host is not allowed to connect to this MySQL server, 试了很多办法都不行 skip-gra ...

  10. Python socket编程应用

    最近因为考试各种复习顺便刷电视剧,感觉跟小伙伴玩的越来越不开心了,一定是最近太闲了,恩.于是想研究一下代理服务器,下载了一份代码,发现竟然还涉及到socket编程,所以把之前网络课的socket聊天室 ...