Binary Numbers(HDU1390)
Binary Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3820 Accepted Submission(s):
2321
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.
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.
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.
#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)的更多相关文章
- 【gym102394B】Binary Numbers(DP)
题意:From https://blog.csdn.net/m0_37809890/article/details/102886956 思路: 可以发现转移就是右上角的一个区间前缀和 std只要开1倍 ...
- 【CF662C】Binary Table(FWT)
[CF662C]Binary Table(FWT) 题面 洛谷 CF 翻译: 有一个\(n*m\)的表格(\(n<=20,m<=10^5\)), 每个表格里面有一个\(0/1\), 每次可 ...
- Humble Numbers(hdu1058)
Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- 【CF55D】Beautiful numbers(动态规划)
[CF55D]Beautiful numbers(动态规划) 题面 洛谷 CF 题解 数位\(dp\) 如果当前数能够被它所有数位整除,意味着它能够被所有数位的\(lcm\)整除. 所以\(dp\)的 ...
- Round Numbers(组合数学)
Round Numbers Time Limit : 4000/2000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Tota ...
- 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 ...
- 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 ...
- Codeforces663E Binary Table(FWT)
题目 Source http://codeforces.com/contest/663/problem/E Description You are given a table consisting o ...
- Gym 100703G---Game of numbers(DP)
题目链接 http://vjudge.net/contest/132391#problem/G Description standard input/outputStatements — It' s ...
随机推荐
- java的GUI编程
目前有三种创建模版产生应用窗体: 第一种: public class MenuDemo implements ActionListener{ //你的组件(成员变量) public MenuDemo( ...
- java设计模式--创建模式--原型模式
原型模式: 原型模式 概述 用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象. 适用性 .当一个系统应该独立于它的产品创建.构成和表示时. .当要实例化的类是在运行时刻指定时,例如,通过 ...
- Php开发官方IDE ZEND
From http://www.zend.com/en/products/studio 注:唯一的缺点是收费.
- JavaScript 输入验证器工具
前注:在数据添加的时候很多地方都会涉及到数据的合法性验证,所以有必要提炼成为一个工具.今天偶然间点错网页,弹出一个游戏界面,本来是想看怎么实现的背景音乐的加载的,结果看到一个注册页面的验证JS,所以这 ...
- Validate Binary Search Tree 解答
Question Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is d ...
- SQLServer 2000 Driver for JDBC][SQLServer]传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确解决方法
问题:[SQLServer 2000 Driver for JDBC][SQLServer]传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确.参数 1 (""): ...
- [转]Activemq管理和基本介绍
1.ActiveMQ服务器工作模型 通过ActiveMQ消息服务交换消息.消息生产者将消息发送至消息服务,消息消费者则从消息服务接收这些消息.这些消息传送操作是使用一组实现 ActiveM ...
- 网站服务器、VPS和虚拟主机的联系与区别
网站服务器是指在互联网数据中心中存放网站的服务器.主要用于网站的互联网中的发布.应用,是网络应用的基础硬件设施.简单的说服务器就是一台电脑,只是这台电脑因为要24 小时高速运行,所以配置要比一般的家 ...
- [Node.js]在windows下不得不防的小错误
TypeError: Arguments to path.join must be strings at f (path.js:204:15) at Object.filter (native) at ...
- 【计算几何初步-代码好看了点线段相交】【HDU2150】Pipe
题目没什么 只是线段相交稍微写的好看了点 Pipe Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...