URAL 1081 Binary Lexicographic Sequence

第13个位置第5个Bit :13>num[4] =>1 第四个bit 13-num[4]=5 :5<num[3] =>0 ,3-1 第三个Bit 5>num[2](3) 5-num[2]=2 ...
#include<stdio.h> int num[]; void init()
{
num[]=;
num[]=;
int k=;
while(k<)
{
num[k]=num[k-]+num[k-];
k++;
}
} int main(void)
{
init();
int n,k;
while(scanf("%d%d",&n,&k)!=EOF)
{
if(k>num[n])
printf("-1\n");
else
{
while(n)
{
if(k>num[n-])
{
putchar('');
k-=num[n-];
}
else
putchar('');
n--;
}
putchar('\n');
}
}
return ;
}
URAL 1081 Binary Lexicographic Sequence的更多相关文章
- 递推DP URAL 1081 Binary Lexicographic Sequence
题目传送门 题意:问第k个长度为n的01串是什么(不能有相邻的1) 分析:dp[i][0/1] 表示前i个,当前第i个放1或0的方案数,先预处理计算,dp[i][1]只能有dp[i-1][0]转移过来 ...
- D - Binary Lexicographic Sequence URAL - 1081 (贪心)
题目链接:https://cn.vjudge.net/contest/275079#problem/D 具体思路:首先,我们可以观察到1-n位数的种数连起来是一个很有规律的数列,然后我们开始倒序建立. ...
- CJOJ 1976 二叉苹果树 / URAL 1018 Binary Apple Tree(树型动态规划)
CJOJ 1976 二叉苹果树 / URAL 1018 Binary Apple Tree(树型动态规划) Description 有一棵苹果树,如果树枝有分叉,一定是分2叉(就是说没有只有1个儿子的 ...
- ural 1247. Check a Sequence
1247. Check a Sequence Time limit: 0.5 secondMemory limit: 64 MB There is a sequence of integer numb ...
- URAL 1018 Binary Apple Tree(树DP)
Let's imagine how apple tree looks in binary computer world. You're right, it looks just like a bina ...
- ural 1018 Binary Apple Tree(树形dp | 经典)
本文出自 http://blog.csdn.net/shuangde800 ------------------------------------------------------------ ...
- URAL 1081
题目大意:求词典序下第K个长度为N且无相邻位置都为1的0.1序列.无解时输出-1. 例如: input: output: 3 1 000(所有符合条件的序列有:000,001,0 ...
- Ural 1018 Binary Apple Tree
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1018 Dynamic Programming. 首先要根据input建立树形结构,然后在 ...
- URAL DP第一发
列表: URAL 1225 Flags URAL 1009 K-based Numbers URAL 1119 Metro URAL 1146 Maximum Sum URAL 1203 Scient ...
随机推荐
- Kill 正在执行的存储过程
1.找到正在执行的存储过程的 sid ,serial# select b.sid,b.SERIAL#,a.OBJECT, 'alter system kill session ' || ''' ...
- asp.net数据库操作类(二)
第二版的数据库访问类出炉了: C# Code 123456789101112131415161718192021222324252627282930313233343536373839404142 ...
- 用Ultraiso刻录U盘装系统
一.准备工作: 1.一个U盘,也可以是手机或数码相机内存卡通过读卡器与电脑连接: 2.一个系统ISO镜像: 3.刻录软件UltraISO,用单文件绿色版就可以了. 二.开始刻录U盘: 1.启动Ultr ...
- https://repo1.maven.org/maven2/com/github/,开源软件清单list
Index of /maven2/com/github/ ../ 0312birdzhang/ 26-Jun-2015 07:21 - 120011676/ 22-Mar-2016 11:16 - 1 ...
- [Leetcode][Python]30: Substring with Concatenation of All Words
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 30: Substring with Concatenation of All ...
- 雕爷牛腩这样判断零售未来-搜狐IT
雕爷牛腩这样判断零售未来-搜狐IT 雕爷牛腩这样判断零售未来
- lodash的中文文档(不全)
http://dingliang-321.iteye.com/blog/2184747
- Andrew Ng Machine learning Introduction
1. 机器学习的定义:Machine learning is programming computers to optimize a performance criterion(优化性能标准) usi ...
- hdu5461 Largest Point(沈阳网赛)
Largest Point Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total ...
- AS3游戏中可视对象上限及位图相关的内存消耗实测
前些天连续做了一些测试,以加深对AS3的掌握和在项目中对 游戏 性能.效率优化方面的一些处理,有很多测试实际意义不大,都不过是证明一些猜想是正确的,除此没有什么. 但前天进行的一系列测试中,有一些对游 ...