链接

好久没写这种逐位计数的了。

先统计出总的数 ,s-n+1,倒着计算的 ,感觉倒着比较符合计算方式,总数为15*A(15,i) (1=<i<=8) 也就是1-8长度所有的排列总数

然后依次从长度1加起 加到第一个>=n的 就找到了 该字符串的长度 然后再逐位进行找下一位 首位不为0.

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
LL s;
LL c[][];
int a[];
bool vis[];
void init()
{
int i,j;
for(i = ; i <= ; i++)
{
c[i][] = ;
for(j = ; j <= i; j++)
{
int k = j,g=i;
c[i][j] = ;
while(k)
{
c[i][j]*=g;
k--;
g--;
}
}
}
for(i = ;i <= ; i++)
{
s+=*c[][i-];
}
}
int main()
{
int i,j,g,e;
LL n;
init();
while(cin>>n)
{
memset(vis,,sizeof(vis));
n = s-n+;
LL ans=;
int ts = ,len;
for(i = ; i <= ; i++)
{
ans+=*c[][i-];
if(ans>=n)
{
n = n-ans+*c[][i-];
len = i;
break;
}
}
int o = ;
for(i = len ; i>= ; i--)
{
ans = ;
int kk;
int tt;
if(i==len) tt = ;
else tt = ;
for(i==len?j = :j=; j <= ; j++)
{
if(vis[j]) continue;
ans+=c[-o][i-];
if(ans>=n)
{
n = n-ans+c[-o][i-];
a[i] = j;
vis[j] = ;
o++;
break;
}
kk = j;
}
}
for(j = len ; j >= ; j--)
{
if(a[j]>=)
printf("%c",a[j]-+'A');
else
cout<<a[j];
}
puts("");
}
return ;
}

poj1715Hexadecimal Numbers(数位dp)的更多相关文章

  1. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP)

    2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP) 链接:https://ac.nowcoder.com/acm/contest/163/ ...

  2. codeforces 55D - Beautiful numbers(数位DP+离散化)

    D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...

  3. Codeforces Beta Round #51 D. Beautiful numbers 数位dp

    D. Beautiful numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/p ...

  4. poj 3252 Round Numbers(数位dp 处理前导零)

    Description The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, P ...

  5. uva 10712 - Count the Numbers(数位dp)

    题目链接:uva 10712 - Count the Numbers 题目大意:给出n,a.b.问说在a到b之间有多少个n. 解题思路:数位dp.dp[i][j][x][y]表示第i位为j的时候.x是 ...

  6. SPOJ BALNUM - Balanced Numbers - [数位DP][状态压缩]

    题目链接:http://www.spoj.com/problems/BALNUM/en/ Time limit: 0.123s Source limit: 50000B Memory limit: 1 ...

  7. SPOJ10606 BALNUM - Balanced Numbers(数位DP+状压)

    Balanced numbers have been used by mathematicians for centuries. A positive integer is considered a ...

  8. Codeforces 914 C. Travelling Salesman and Special Numbers (数位DP)

    题目链接:Travelling Salesman and Special Numbers 题意: 给出一个二进制数n,每次操作可以将这个数变为其二进制数位上所有1的和(3->2 ; 7-> ...

  9. Educational Codeforces Round 8 D. Magic Numbers 数位DP

    D. Magic Numbers 题目连接: http://www.codeforces.com/contest/628/problem/D Description Consider the deci ...

  10. POJ3252 Round Numbers —— 数位DP

    题目链接:http://poj.org/problem?id=3252 Round Numbers Time Limit: 2000MS   Memory Limit: 65536K Total Su ...

随机推荐

  1. SQL - 创建一个学生表,要求有主键约束和非空约束

    CREATE TABLE [dbo].[Student] ( [ID] [int] NOT NULL, [Name] [nchar](10) NOT NULL, [Age] [int] NOT NUL ...

  2. Linux-github 搭建静态博客

    1.在Github上创建一个新的Repository 到你的github上 https://github.com去create a new repository命名为 github.myblog 2. ...

  3. 笔记本 ThinkPad E40 安装 Mac OS X 10.9.3 Mavericks 系统

    关于:自己最早接触Mac OS X系统是在一个论坛里.记得好像是2011年:那时论坛里就有人在虚拟机上执行Mac OS X 10.7系统.当时也依照论坛里的方法在虚拟机上成功装上了系统.那时開始就被苹 ...

  4. C++语言笔记系列之二十——模版

    1.随意输入两个数x和y,输出最大值max. int max(int x, int y) {return x>y? x:y;} 2.函数模版 (1)用一种或者多种通用类型去表示函数--函数模版. ...

  5. C语言-- static 全局使用示例

    C语言-- static 全局使用示例  前言:看到很多使用Objective-C开发IOS的大牛,有时候会使用static全局变量,相比之下,我却很少用这个,从而很少对其有着比较有实质意义的理解,甚 ...

  6. MVC+ZTree实现对树的CURD及拖拽操作

    上一讲中,我们学习了如何使用zTree对一棵大树(大数据量的树型结构的数据表,呵呵,名称有点绕,但说的是事实)进行异步加载,今天这讲,我们来说说,如何去操作这棵大树,无非就是添加子节点,删除节点,编辑 ...

  7. NHibernate查询导致Update问题

    用NHibernate,总感觉怪事多罗罗. 比如说,明明我们是在查询,却报错,刨根问底找到出错原因,竟然是因为执行了一些Update甚至Insert!老天,我们明明只是查询而已,什么时候有更新过数据? ...

  8. 提高比特率 有损 无损 Video-and-Audio-file-format-conversion 视频声音转码

    3 Ways to Change Bitrate on MP3 Files https://www.online-tech-tips.com/software-reviews/change-bitra ...

  9. git lfs

    https://git-lfs.github.com/ 1.从这个网址下载git-lfs-windows-amd64-1.1.0.exe,运行这个安装包 2.然后打开git bash 输入git lf ...

  10. BZOJ_2099_[Usaco2010 Dec]Letter 恐吓信_后缀自动机+贪心

    BZOJ_2099_[Usaco2010 Dec]Letter 恐吓信_后缀自动机 Description FJ刚刚和邻居发生了一场可怕的争吵,他咽不下这口气,决定佚名发给他的邻居 一封脏话连篇的信. ...