链接

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

先统计出总的数 ,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. Unity 3D 中动态字体的创建

    原创不易,转载请注明转自: http://blog.csdn.net/u012413679/article/details/26232453 ---- kosion 1.载入NGUI插件包,载入完毕后 ...

  2. openstack kolla多节点容器化环境安装

    好久没写随笔了,6月份趁着在公司没有太忙的事儿,把公司的服务器进行了虚拟化,采用的openstack当前的容器化方案kolla. 整体安装完的感受时,小白感觉自己是个大牛!哈哈,开玩笑,由于以前是开发 ...

  3. mingw在Dos下升级gnu编译器版本

    在dos窗口下输入: mingw-get update mingw-get upgrade gfortran gcc g++ 强烈建议卸载后再安装新版本

  4. Xcode The identity used to sign the executable is no longer valid. 错误解决

    Xcode真机调试时出现问题:Xcode The identity used to sign the executable is no longer valid. Please verify that ...

  5. leetCode 81.Search in Rotated Sorted Array II (旋转数组的搜索II) 解题思路和方法

    Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this ...

  6. HDU 1015 Safecracker(第一次用了搜索去遍历超时,第二次用for循环能够了,思路一样的)

    Safecracker Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total S ...

  7. LIKIE INSTR

    SELECT  url FROM test_url WHERE   FROM_UNIXTIME(create_time,'%Y%m%d %H') < '20171218 00'  AND  no ...

  8. grails Domian对象转JSON去class以及自己定义字段的最佳方式

    grails:2.4.x IDE:Intellij IDEA 13.x grails的Domain对象之间假设存在环形引用.直接使用as JSON仅仅会输出关联对象的id.而且假设使用deep也会报错 ...

  9. 有向图强连通分量的Tarjan算法(转)

    [有向图强连通分量] 在有向图G中,如果两个顶点间至少存在一条路径,称两个顶点强连通(strongly connected).如果有向图G的每两个顶点都强连通,称G是一个强连通图.非强连通图有向图的极 ...

  10. bzoj1007 [HNOI2008]水平可见直线——单调栈

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1007 可以把直线按斜率从小到大排序,用单调栈维护,判断新直线与栈顶的交点和栈顶与它之前直线的 ...