链接

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

先统计出总的数 ,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. D广搜

    <span style="color:#330099;">/* D - 广搜 基础 Time Limit:1000MS Memory Limit:30000KB 64b ...

  2. [IT新应用]brave浏览器

    https://www.brave.com/about.html The web has become a different place. With the ad-tech ecosystem ou ...

  3. CSS的两个class选择器紧挨在一起

    有一段HTML代码: <a class="glyphicons white no-js cogwheel" href="#" target="_ ...

  4. 转载 Url编码

    http://www.cnblogs.com/artwl/archive/2012/03/07/2382848.html 混乱的URI编码 JavaScript中编码有三种方法:escape.enco ...

  5. java8--网络编程(java疯狂讲义3复习笔记)

    重点复习一下网络通信和代理 java的网络通信很简单,服务器端通过ServerSocket建立监听,客户端通过Socket连接到指定服务器后,通信双方就可以通过IO流进行通信. 需要重点看的工具类:I ...

  6. perl BEGIN block and END block

    1 本质上就是一段代码 BEGIN在程序运行前执行,END在程序运行之后执行. 2 BEGIN END的行为和所在的位置无关 也就是说,无论BEGIN和END block位于代码的哪里,最先执行的是B ...

  7. 【java报错】CacheLoader returned null for key class

    CacheLoader returned null for key class cmd     mvn eclipse:clean eclipse:eclipse mvn install -Dmave ...

  8. Apache POI组件操作Excel,制作报表(四)

    Apache POI组件操作Excel,制作报表(四) 博客分类: 探索实践 ExcelApacheSpringMVCServlet      上一篇我们介绍了如何制作复杂报表的分析和设计,本篇结合S ...

  9. CodeForces-451E:Devu and Flowers (母函数+组合数+Lucas定理)

    Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contain ...

  10. [TJOI2016&HEOI2016] 排序

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=4552 [算法] 首先 , 二分答案x , 将比x小的数看作1,比x大的数看作0 然后 ...