HDU-1390 Binary Numbers
http://acm.hdu.edu.cn/showproblem.php?pid=1390
Binary Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2298 Accepted Submission(s): 1460
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.
Each data set consists of exactly one line containing exactly one integer n, 1 <= n <= 10^6.
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<stdio.h>
int main()
{
int d,n,r,a[],j,i,f;
scanf("%d",&d);
while(d--)
{
j=;
scanf("%d",&n);
while(n!=)
{
r=n%;
a[j++]=r;
n=n/;
}
for(i=;i<j;i++)
if(a[i]==)
{
f=i;
printf("%d",i);
break;
}
for(i=f+;i<j;i++)
if(a[i]==)
printf(" %d",i);
printf("\n");
}
return ;
}
HDU-1390 Binary Numbers的更多相关文章
- HDOJ 1390 Binary Numbers(进制问题)
Problem Description Given a positive integer n, find the positions of all 1's in its binary represen ...
- Binary Numbers(HDU1390)
Binary Numbers 点我 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- 【数位DP】 HDU 4722 Good Numbers
原题直通车: HDU 4722 Good Numbers 题意: 求区间[a,b]中各位数和mod 10==0的个数. 代码: #include<iostream> #include& ...
- HDU 3117 Fibonacci Numbers(围绕四个租赁斐波那契,通过计++乘坐高速动力矩阵)
HDU 3117 Fibonacci Numbers(斐波那契前后四位,打表+取对+矩阵高速幂) ACM 题目地址:HDU 3117 Fibonacci Numbers 题意: 求第n个斐波那契数的 ...
- HDOJ(HDU).1058 Humble Numbers (DP)
HDOJ(HDU).1058 Humble Numbers (DP) 点我挑战题目 题意分析 水 代码总览 /* Title:HDOJ.1058 Author:pengwill Date:2017-2 ...
- Codeforces Round #515 (Div. 3) E. Binary Numbers AND Sum
E. Binary Numbers AND Sum 题目链接:https://codeforces.com/contest/1066/problem/E 题意: 给出两个用二进制表示的数,然后将第二个 ...
- zoj 1383 Binary Numbers
Binary Numbers Time Limit: 2 Seconds Memory Limit: 65536 KB Given a positive integer n, print o ...
- 【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 ...
- 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 ...
随机推荐
- PHP pear安装出现 Warning: require_once(Structures/Graph.php)...错误
今天在WINDOWS安装pear,一路无阻很顺利安装完成,接着想安装下pear email包来玩下,但接下来却报: Warning: require_once(Structures/Graph.php ...
- js生成动态日历
效果图: 看代码: <html> <head> <title>动态日历</title> <style type="text/css& ...
- autoplay media studio couldn't load
AutoPlay Media Studio 7 (English version) is installed on target machine. Following error occurred w ...
- centOS 6.4 vsftpd 安装配置
参考 http://blog.csdn.net/wocjj/article/details/7418944 配置说明 http://www.cnblogs.com/redhatlinux/arc ...
- oracle安装,配置,启动
因为主要不是讲oracle这些,所以就略写. 注意安装的时候:确保以前安装过的卸载干净了.安装的路径不能包含中文.安装的时候需要创建两层数据库.因为在选择的安装目录的平行目录会产生文件. 确认卸载完可 ...
- OS概论1
1.设计现代OS的主要目标是什么? 在计算机上配置操作系统,其主要目标是:方便性,有效性,可扩充性,开放性. 一个没有OS的操作系统,就必须用机器语言书写程序,如果在计算机上配置了OS,系统便可以使用 ...
- [转]Python中的矩阵转置
Python中的矩阵转置 via 需求: 你需要转置一个二维数组,将行列互换. 讨论: 你需要确保该数组的行列数都是相同的.比如: arr = [[1, 2, 3], [4, 5, 6], [7, 8 ...
- 查看Oracle表空间使用情况与增大表空间
1,查看表空间使用情况 SELECT D.TABLESPACE_NAME, SPACE || 'M' "SUM_SPACE(M)", BLOCKS "SUM_BLOCKS ...
- RESTheart官方文档
作者:Andrea Di Cesare, Maurizio Turatti RESTHeart是SoftInstigate公司创建并开发的开源项目. MongoDB的WEB操作接口 RESTHEART ...
- 解决ubuntu侧边栏固定应用单击无反应的问题
Linux下有些绿色软件,不需要安装就可以双击启动,但有些程序在打开后直接在 Launcher 中右键选择 Lock to Launcher ,但是,有时候单击图标后并未启动应用,下面给出解决方法. ...