HDU 1339 A Simple Task
来源:互联网 发布:在淘宝上怎么搜索发票 编辑:程序博客网 时间:2024/06/16 23:12
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.ExampleFor n = 24, o = 3 and p = 3.TaskWrite 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和p满足式子n = o2^p。运算量不大,直接穷举。
#include<cstdio>#include<cstring>#include<cmath>using namespace std;int main(){ int k,i,j,n,t; scanf("%d",&t); while(t--) { scanf("%d",&n); for(j=0; j<20; j++) { k=1<<j; i=n/k; if(i%2&&i*k==n) { printf("%d %d\n",i,j); break; } } } return 0;}
- HDU 1339 ( A Simple Task )
- HDU 1339 A Simple Task
- HDU A Simple Task
- hdu 1339 A Simple Task(水)
- HDU 1339 || ZOJ 1382 A Simple Task
- hdu 1339 A Simple Task 数学题
- hdu-oj 1339 A Simple Task
- HDU 1339 A Simple Task【数学题】
- 杭电 HDU ACM 1339 A Simple Task
- HDU 1339 A Simple Task(暴力枚举)
- HDU 1339 A Simple Task
- 杭电ACM 1339 A Simple Task
- hdoj.1339 A Simple Task 20140821
- HDOJ 1339 A Simple Task(水题)
- HDU1339:A Simple Task
- hdu1339-A Simple Task
- CF11D A Simple Task
- A Simple Task
- java基础--Set、List和Map的区别
- genymotion的安装和使用
- 【杭电oj2024】C语言合法标识符
- RecyclerView 的使用详解(一)
- php中json_decode()和json_encode()的使用方法
- HDU 1339 A Simple Task
- 线段树总结
- 3.使用cvPyrDown()缩放图像(一个复杂一点的变换)
- Java设计模式—工厂方法
- 如何实现自定义的ProgressBar
- CentOS6.5更改MySQL数据库为5.6版
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1001 A water problem hdu5832
- 【杭电oj2030】汉字统计
- Perl正则表达式