ZOJ 1383: Binary Numbers
来源:互联网 发布:非淘宝会员什么意思 编辑:程序博客网 时间:2024/04/30 05:31
求十进制数转换成二进制之后都有第几位(从低往高数,另外定义最低位叫第0位) 是1
题目说了输入不大于1,000,000的十进制数 ->所以不需要用高精度,直接int就能AC
根据直觉写代码就直接AC了
判断数字除2的余数 如果余1,那么第0位就是1,输出'0'
然后数字除以2取整,再判断第1位,以此类推
最高位一定是1,直接输出
难度系数=0
通过率数据:37.96% (5199/13693)
import java.util.*;public class Main {public static int d;public static int n;public static int i;public static int x;public static void main(String[] args) {Scanner in = new Scanner(System.in);d=in.nextInt();for (i=0;i<d;i++){n=in.nextInt();x=0;while (n>1){if ((n%2)==1) System.out.printf("%d ",x);n/=2;x++;}System.out.printf("%d\n", x);}}}
- zoj 1383 Binary Numbers
- ZOJ 1383 Binary Numbers
- zoj 1383 Binary Numbers
- ZOJ 1383 Binary Numbers
- ZOJ 1383: Binary Numbers
- ZOJ 1383 Binary Numbers
- zoj 1383 Binary Numbers
- zoj 1383 Binary Numbers
- ZOJ 1383 Binary Numbers
- HDU 1390 || ZOJ 1383 Binary Numbers
- ZOJ Problem Set - 1383 Binary Numbers
- ZOJ Problem Set - 1383 Binary Numbers
- ZOJ Problem Set - 1383 Binary Numbers
- zoj 1383.Binary Numbers
- zoj 1383 Binary Numbers&&zoj 1491 Climbing Worm(简单)
- Binary Numbers
- Binary Numbers
- Binary Numbers
- VB.net 定时关机程序(WPF)
- 本地动态SQL执行DML语句
- OK6410 修改调试串口为普通串口
- Ubuntu使用笔记——SVN
- C++ inline constexpr 内联函数和常量表达式函数问题
- ZOJ 1383: Binary Numbers
- 动态SQL execute immediate into 过程
- 串口编程 tcflush()函数
- 参加2013年大连软件开发者大会
- cocos2d-x之testlua学习
- ZOJ 1382: A Simple Task
- ubuntu10安装ideaiu12出现错误解决
- USACO Closed Fences 解题报告
- 用java语言实现各种进制转换(二进制,八进制,十进制,十六进制互转,主要使用Java Swing技术)