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. Windows7上FTP服务器建立

    1. FTP服务器建立 注意:千万不能使用FTP和ftp建立用户,否则无法登陆ftp服务器. 1.1本地机器上创建一个用户 这个用户是用来登录到FTP的.我的电脑右键->管理->本地用户和 ...

  2. 图片ppm编码格式

    ppm图片有2种格式, ASCII格式和binary格式. (1)ppm头部分 由三部分组成,这三部分由回车或换行分割,但PPM的标准中是要求空格. 第一行通常是P3或P6,说明是PPM格式: 第二行 ...

  3. Sad Angel (悲伤的天使)-Игорь Крутой

    悲伤的天使(neyanbhbin) -经典作曲Sad Angel( Печальныйангел)生活是一种连续的影响,每个小人物都有小人物的伟大故事.从开头的情侣,到美丽的丝带,从清洁老伯到卖气球的 ...

  4. nginx+mysql+php

    根据生产环境安装操作系统(centos 6.0 64位系统),安装完成后,使用Xshell通过ssh协议连接服务器.ssh 用户名@IP+回车+输入密码后登录系统.#mkdir -p /home/to ...

  5. Anniversary party(POJ 2342 树形DP)

    Anniversary party Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5767   Accepted: 3335 ...

  6. Typecho 代码阅读笔记(一) - 页面渲染及路由机制

    转载请注明出处:http://blog.csdn.net/jh_zzz 从 index.php 开始看, /** 初始化组件 */ Typecho_Widget:: widget('Widget_In ...

  7. Median of Two Sorted Arrays (找两个序列的中位数,O(log (m+n))限制) 【面试算法leetcode】

    题目: There are two sorted arrays A and B of size m and n respectively. Find the median of the two sor ...

  8. Ajax跨域访问解决办法

    方法1. jsonp实现ajax跨域访问示例 jsp代码: <body> <input type="button" onclick="testJsonp ...

  9. SQL注入原理深度解析

    本文转自:http://www.iii-soft.com/forum.php?mod=viewthread&tid=1613&extra=page%3D1 对于Web应用来说,注射式攻 ...

  10. python中使用mahotas包实现高斯模糊

    高斯模糊 import mahotas as mh import numpy as np from matplotlib import pyplot as plt image=mh.imread('i ...