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 ...
随机推荐
- react native ios 开发,基础配置笔记。
一.获取硬件信息,使用react-native-device-info插件,配置说明: 1.首先需要安装组件:npm install react-native-device-info --save 2 ...
- (hdu)5652 India and China Origins 二分+dfs
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5652 Problem Description A long time ago there ...
- cocos2dx如何添加popScene的场景动画
说明 我们很容易在pushScene中添加动画 Director::getInstance()->pushScene(TransitionSlideInB::create(SCENE_TIME, ...
- ASP.NET中的特殊路径标识"~"
/ 表示网站根目录(从域名开始), ../ 表示上级目录, ./表示当前目录- 是ASP.NET定义的特殊符号,是ASP.NET内部进行定义推荐的用法,-代表从应用根目录开始定义应用根目录与网站根目录 ...
- 思维导图软件VYM
http://www.insilmaril.de/vym/ 点击打开链接http://www.oschina.net/p/vym 有人说VYM就跟目录是一回事,确实是这样, 只不过与excel之类的比 ...
- 【原创】Android多个xml文件的使用
Android中经常会使用多个xml文件,但在Mainactivity中使用的setContentView(R.layout.main)只加载main.xml文件,其他xml文件不加载进当前视图,当我 ...
- c#语音
1.新建WinForm程序,项目名称命名为Speech. 2.在COM组件中添加SpeechLib的引用. using SpeechLib;//添加语音引用 添加一个文本框并将其重命名为txtCont ...
- [C#]『Barrier』任务并行库使用小计
Barrier 是一个对象,它可以在并行操作中的所有任务都达到相应的关卡之前,阻止各个任务继续执行. 如果并行操作是分阶段执行的,并且每一阶段要求各任务之间进行同步,则可以使用该对象. --MSDN ...
- HTML块
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- 小笔记(二):php数组
一.对于一二维数组重新组合为另一个二维数组,根据键值名称对一个二维数组进行重新组合例: /*$paramArray=array( * 'a'=>array('0'=>'1','1'=> ...