Binary Numbers

点我

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

Problem Description
Given a positive integer n, find the positions of all
1's in its binary representation. The position of the least significant bit is
0.

Example

The positions of 1's in the binary representation
of 13 are 0, 2, 3.

Task

Write a program which for each data
set:

reads a positive integer n,

computes the positions of 1's in
the binary representation of n,

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, should contain increasing
sequence of integers separated by single spaces - the positions of 1's in the
binary representation of the i-th input number.

 
Sample Input
1
13
 
Sample Output
0 2 3
 #include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
int T;
cin>>T;
while(T--)
{
int n,i=,j,k,flag=;
cin>>n;
while(n)
{
if(n%==)
{
cout<<i;
if(n>=)
cout<<' ';
}
i++;
n/=;
}
cout<<endl;
}
}
 
 

Binary Numbers(HDU1390)的更多相关文章

  1. 【gym102394B】Binary Numbers(DP)

    题意:From https://blog.csdn.net/m0_37809890/article/details/102886956 思路: 可以发现转移就是右上角的一个区间前缀和 std只要开1倍 ...

  2. 【CF662C】Binary Table(FWT)

    [CF662C]Binary Table(FWT) 题面 洛谷 CF 翻译: 有一个\(n*m\)的表格(\(n<=20,m<=10^5\)), 每个表格里面有一个\(0/1\), 每次可 ...

  3. Humble Numbers(hdu1058)

    Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T ...

  4. 【CF55D】Beautiful numbers(动态规划)

    [CF55D]Beautiful numbers(动态规划) 题面 洛谷 CF 题解 数位\(dp\) 如果当前数能够被它所有数位整除,意味着它能够被所有数位的\(lcm\)整除. 所以\(dp\)的 ...

  5. Round Numbers(组合数学)

    Round Numbers Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Tota ...

  6. PAT 甲级 1023 Have Fun with Numbers(20)(思路分析)

    1023 Have Fun with Numbers(20 分) Notice that the number 123456789 is a 9-digit number consisting exa ...

  7. Codeforces F. Vus the Cossack and Numbers(贪心)

    题目描述: D. Vus the Cossack and Numbers Vus the Cossack has nn real numbers aiai. It is known that the ...

  8. Codeforces663E Binary Table(FWT)

    题目 Source http://codeforces.com/contest/663/problem/E Description You are given a table consisting o ...

  9. Gym 100703G---Game of numbers(DP)

    题目链接 http://vjudge.net/contest/132391#problem/G Description standard input/outputStatements — It' s ...

随机推荐

  1. Python之路第十二天,高级(4)-Python操作rabbitMQ

    rabbitMQ RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统.他遵循Mozilla Public License开源协议. MQ全称为Message Queue, 消息队列(M ...

  2. python 核心编程第六章课后题自己做的答案

    6–6. 字符串.创建一个 string.strip()的替代函数:接受一个字符串,去掉它前面和后面的 空格(如果使用 string.*strip()函数那本练习就没有意义了) 'Take a str ...

  3. opencv学习之旅_绘制跟踪轨迹

    如何将运动物体的轨迹画出来 我的想法是先:用CAMSHIFT跟踪物体,这个函数会返回一个track_box,将box的中心提取出来,然后以这个中心在另外的图像上画出来,然后将这张图像处理,提取轮廓,提 ...

  4. cxf2.7.10 与 spring3.0.5集成

    开发环境: NetBeans7.4 Tomcat 6.0.32 一 服务端: 1:新建JavaWeb工程 cxfspring-server,导入jar包如下图所示: 2:在web.xml文件中添加如下 ...

  5. 微控制器(MCU)破解秘笈--背景知识

    2.1 硅芯片安全措施的演变 工业控制器的硬件安全措施与嵌入式系统同时开始发展.三十年前的系统是由分离的部件如CPU,ROM,RAM,I/O缓冲器,串口和其他通信与控制接口组成的.如图2-1所示: 图 ...

  6. UESTC_韩爷的情书 2015 UESTC Training for Graph Theory<Problem H>

    H - 韩爷的情书 Time Limit: 6000/2000MS (Java/Others)     Memory Limit: 262144/262144KB (Java/Others) Subm ...

  7. Maximum Depth of Binary Tree 解答

    Question Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along ...

  8. MongoDb Windows linux平台环境及主流编程语言驱动安装同时配置mongoDb的远程连接

    <一,>MongoDB 简介篇Ruiy; MongoDB是一个高性能,开源,无模式的文档型数据库,是当前NoSql数据库中比较热门的一种.它在许多场景下可用于替代传统的关系型数据库或键/值 ...

  9. Python递归函数与斐波那契数列

    定义:在函数内部,可以调用其他函数.如果一个函数在内部调用自身本身,这个函数就是递归函数. 阶乘实例 n = int(input(">>:")) def f(n): s ...

  10. 小明系列问题——小明序列(Lis 相距大于d的单调上升子序列)

    小明系列问题——小明序列 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Tot ...