Binary Numbers


Time Limit: 2 Seconds      Memory Limit: 65536 KB

Given a positive integer n, print out 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>
#include <vector>
using namespace std;
int main(){
int d, n, flag;
vector<int> v;
cin >> d;
while(cin >> n){
v.clear();
while(n){
int t = n % ;
v.push_back(t);
n >>= ;
}
flag = ;
for(int i = ; i < v.size(); i++){
if(v[i] == ){
if(flag == ){
cout << i;
flag = ;
} else {
cout << " " << i;
}
}
}
cout << endl;
}
//system("pause");
return ;
}

zoj 1383 Binary Numbers的更多相关文章

  1. ZOJ Problem Set - 1383 Binary Numbers

    水题,输出的时候注意下 #include <stdio.h> #include <math.h> int main() { int d; scanf("%d" ...

  2. HDU-1390 Binary Numbers

    http://acm.hdu.edu.cn/showproblem.php?pid=1390 Binary Numbers Time Limit: 2000/1000 MS (Java/Others) ...

  3. Binary Numbers(HDU1390)

    Binary Numbers 点我 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  4. Codeforces Round #515 (Div. 3) E. Binary Numbers AND Sum

    E. Binary Numbers AND Sum 题目链接:https://codeforces.com/contest/1066/problem/E 题意: 给出两个用二进制表示的数,然后将第二个 ...

  5. 【Leetcode_easy】1022. Sum of Root To Leaf Binary Numbers

    problem 1022. Sum of Root To Leaf Binary Numbers 参考 1. Leetcode_easy_1022. Sum of Root To Leaf Binar ...

  6. LeetCode 1022. 从根到叶的二进制数之和(Sum of Root To Leaf Binary Numbers)

    1022. 从根到叶的二进制数之和 1022. Sum of Root To Leaf Binary Numbers 题目描述 Given a binary tree, each node has v ...

  7. [Swift]LeetCode1022. 从根到叶的二进制数之和 | Sum of Root To Leaf Binary Numbers

    Given a binary tree, each node has value 0 or 1.  Each root-to-leaf path represents a binary number ...

  8. ZOJ - 2243 - Binary Search Heap Construction

    先上题目: Binary Search Heap Construction Time Limit: 5 Seconds      Memory Limit: 32768 KB Read the sta ...

  9. Binary Numbers AND Sum CodeForces - 1066E (前缀和)

    You are given two huge binary integer numbers aa and bb of lengths nn and mmrespectively. You will r ...

随机推荐

  1. KEIL软件仿真死在等待外部晶振起振

    这是由于是Debug里面的设置有问题 主要是下面2项设置 Dialog DLL默认是DCM3.DLL Parameter默认是-pCM3 应改为 Dialog DLL默认是DARMSTM.DLL Pa ...

  2. EmitMapper系列之一:EmitMapper入门

    EmitMapper的总结 EmitMapper简介 前言: 参考官网: http://emitmapper.codeplex.com/ Project Description Powerful cu ...

  3. CG Shader常用函数

    为了方便自己记忆,将常用的CG函数写于此 转载于 http://www.cppblog.com/lai3d/archive/2008/10/23/64889.html Name Syntax Desc ...

  4. Git-远程操作

    远程分支:远程跟踪分支remote branch是对远程分支状态的引用,是不能移动的,它会根据远程分支变化以及网络通信自动移动.Git服务器包含了远程分支master,在My Computer中的re ...

  5. 在WIN7下解决coursera视频无法播放问题

    https://blog.csdn.net/u012509485/article/details/78459584在WIN7下解决coursera视频无法播放问题2019/1/20 23:18 最近C ...

  6. git diff查看修改,出现^M换行问题

    通过命令git diff查看修改,出现^M换行问题,如图: 解决: git config --global core.whitespace cr-at-eol 换行符的问题: 提交时转换为LF,检出时 ...

  7. EMAC IP 核

    在有线连接的世界里,以太网(Ethernet)无所不在.以太网具有各种速度模式.接口方式.以及灵活的配置方式.现在的以太网卡都是10/100/1000Mbps自适应网卡.以太网的物理层(PHY)通常使 ...

  8. Linux系统结构与终端控制台

    Linux系统结构与终端控制台 作者:Vashon 时间:20150418 以下主要是对Linux系统终端控制台切换及基本操作的范例,其他的理论就不多说了,直接进入实践部分. Starting.... ...

  9. PHP一句话后门过狗姿势万千之理论篇

    写在前面: 过狗相关的资料网上也是有很多,所以在我接下来的文章中,可能观点或者举例可能会与网上部分雷同,或者表述不够全面. 但是我只能说,我所传达给大家的信息,是我目前所掌握或者了解的,不能保证所有人 ...

  10. 基于Zabbix API文档二次开发与java接口封装

    (继续贴一篇之前工作期间写的经验案例) 一.           案例背景 我负责开发过一个平台的监控报警模块,基于zabbix实现,需要对zabbix进行二次开发. Zabbix官方提供了Rest ...