链接

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

先统计出总的数 ,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. A Single Channel with Multiple Consumers RabbitMQ

    http://stackoverflow.com/questions/30696351/a-single-channel-with-multiple-consumers-rabbitmq up vot ...

  2. D广搜

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

  3. 纯C语言实现简单封装继承机制

    0 继承是OO设计的基础 继承是OO设计中的基本部分,也是实现多态的基础,C++,C#,Objective-C.Java.PHP.JavaScript等为OO而设计的语言,其语言本身对实现继承提供了直 ...

  4. Thinking in Java -- 类型信息RTTI

    Thinking in Java – 类型信息 个人感觉 java 中的比較难的部分了,在看了些netty源代码发现事实上这块很实用. 这章重点是RTTI和反射.先说下自己的理解 RTTI是执行时识别 ...

  5. Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExce

    Error setting property values ; nested exception is org.springframework.beans.NotWritablePropertyExc ...

  6. unix2dos/dos2unix

    dos2unix命令用来将DOS格式的文本文件转换成UNIX格式的(DOS/MAC to UNIX text file format converter).DOS下的文本文件是以\r\n作为断行标志的 ...

  7. XMU 1612 刘备闯三国之桃园结义 【二分】

    1612: 刘备闯三国之桃园结义 Time Limit: 1000 MS  Memory Limit: 128 MBSubmit: 181  Solved: 12[Submit][Status][We ...

  8. 高清摄像头MIPI CSI2接口浅解【转】

    本文转载自:http://blog.csdn.net/u012075739/article/details/44672435 MIPI摄像头常见于手机.平板中,支持500万像素以上高清分辨率.它的全称 ...

  9. C# Stopwatch

    问题一:前几天写并行计算的实际应用——通讯录的时候,用到了stopwatch来计时,发现这个计时是真正的计时. Stopwatch stopwatch = new Stopwatch(); TimeS ...

  10. Ural2102:Michael and Cryptography(数论&素数)

    The hacker Michael develops breakthrough password manager, which is called KEK (Keeper of Encrypted ...