Binary Watch_太阁竞赛A
来源:互联网 发布:法兰克王国 知乎 编辑:程序博客网 时间:2024/04/28 13:28
题目1 : Binary Watch
时间限制:10000ms
单点时限:1000ms
内存限制:256MB
描述
Consider a binary watch with 5 binary digits to display hours (00 - 23) and 6 binary digits to display minutes (00 - 59).
For example 11:26 is displayed as 01011:011010.
Given a number x, output all times in human-readable format "hh:mm" when exactly x digits are 1.
输入
An integer x. (0 ≤ x ≤ 9)
输出
All times in increasing order.
样例输入
1
样例输出
00:01
00:02
00:04
00:08
00:16
00:32
01:00
02:00
04:00
08:00
时间限制:10000ms
单点时限:1000ms
内存限制:256MB
描述
Consider a binary watch with 5 binary digits to display hours (00 - 23) and 6 binary digits to display minutes (00 - 59).
For example 11:26 is displayed as 01011:011010.
Given a number x, output all times in human-readable format "hh:mm" when exactly x digits are 1.
输入
An integer x. (0 ≤ x ≤ 9)
输出
All times in increasing order.
样例输入
1
样例输出
00:01
00:02
00:04
00:08
00:16
00:32
01:00
02:00
04:00
08:00
16:00
【我的程序】
#include <iostream>using namespace std;int compt(int x){ int ans=0; while (x>0){ if (x%2==1) ans++; x/=2; } return ans;}int main(){ int n,a[60]; cin>>n; for (int i=0;i<=59;i++) a[i]=compt(i); for (int i=0;i<=23;i++) for (int j=0;j<=59;j++) if (a[i]+a[j]==n) cout<<i/10 <<i%10 <<':' <<j/10 <<j%10 <<endl; return 0;}
0 0
- Binary Watch_太阁竞赛A
- [hihocoder]太阁最新面经算法竞赛8]A.A Game
- hihoCoder太阁最新面经算法竞赛8 A Game(区间DP)
- Popular Products_太阁竞赛B
- Counting Islands II_太阁竞赛C
- [随便切水题系列]hihoCoder太阁算法竞赛12
- hihoCoder太阁最新面经算法竞赛题解(1)
- hihoCoder太阁最新面经算法竞赛题解(2)
- hihoCoder太阁最新面经算法竞赛题解(3)
- hihoCoder太阁最新面经算法竞赛题解(4)
- hihoCoder太阁最新面经算法竞赛题解(5)
- hihoCoder太阁最新面经算法竞赛题解(6)
- hihoCoder太阁最新面经算法竞赛题解(7)
- 《hihoCoder太阁最新面经算法竞赛4》题目解析【含源代码】
- [hihoCoder 太阁最新面经算法竞赛6] 数组重排(N个数的最小公倍数)
- [hihoCoder太阁最新面经算法竞赛2] 岛屿 (DFS,Hash Function)
- hihoCoder太阁最新面经算法竞赛8 题目2 : Dice Possibility (概率DP)
- [hihoCoder太阁最新面经算法竞赛8]B.Dice Possibility
- [平衡树] [Tyvj P1728] 普通平衡树 (balanced)
- 开始ITGEGE教育社区的视频录制----嵌入式基础知识讲解
- HDOJ 5524 Subtrees(二叉树)
- BestCoder Round #1
- document.write()用法
- Binary Watch_太阁竞赛A
- HDOJ 5734 Acperience(数学运算)
- sqlite第三方类库:FMDB
- Linux驱动学习笔记;字符设备驱动
- HDOJ 5742 It's All In The Mind(数学变形)
- max sub sum II
- Java 过滤器的作用
- ListView上拉加载
- 重学 Statistics, Cha16 General Linear Model