链接

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

先统计出总的数 ,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. 使用PowerShell 创建SharePoint 站点

    使用PowerShell 创建SharePoint 站点         在SharePoint开发中,你应该学会使用PowerShell管理SharePoint网站.SharePoint Manag ...

  2. [读书笔记]流畅的Python(Fluent Python)

    <流畅的Python>这本书是图灵科技翻译出版的一本书,作者Luciano Ramalho. 作者从Python的特性角度出发,以Python的数据模型和特殊方法为主线,主要介绍了pyth ...

  3. struts2的(S2-045,CVE-2017-5638)漏洞测试笔记

    网站用的是struts2 的2.5.0版本 测试时参考的网站是http://www.myhack58.com/Article/html/3/62/2017/84026.htm 主要步骤就是用Burp ...

  4. Ubuntu系统下实现Android工程调用独立编译的C++程序和GMP、PBC库

    目的: 实现使用C++编写代码供Android工程调用.C++代码中可以使用STL库,也可以使用常用的由源码编译生成的库,如PBC.因为PBC是基于GMP库的,所以这里只记录了GMP和PBC库的编译安 ...

  5. Struts2中怎样配置struts。xml?

    <?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-/ ...

  6. BZOJ2874 训练士兵 主席树

    [啊 首先 这是道权限题,然后本人显然是没有权限的  23咳3] 最近数据结构做的越来越少..然后 就跟上次一样 ,一做就是三四种不同写法. 等价的题面: 最近GY大神在sc2的天梯中被神族虐得很惨, ...

  7. 【转】python字符串/元组/列表/字典互转

    #-*-coding:utf-8-*- #1.字典 dict = {'name': 'Zara', 'age': 7, 'class': 'First'} #字典转为字符串,返回:<type ' ...

  8. 更改Identity用户信息

    1.用当前上下文对象初始化为一个一个UserStote 对象,然后使用 userstore对象 初始化一个UserManagement对象.找到这个对象,然后更新它的部分属性.然后调用 manager ...

  9. [软件安装]MYSQL

    https://dev.mysql.com/downloads/repo/yum/ wget https://repo.mysql.com//mysql57-community-release-el7 ...

  10. ThinkPHP3.2.3学习笔记2---模型

    一.模型实例化1.直接实例化可以和实例化其他类库一样实例化模型类,例如:$User = new \Home\Model\UserModel();$Info = new \Admin\Model\Inf ...