题: https://nanti.jisuanke.com/t/41414

#include<bits/stdc++.h>
using namespace std;
typedef __int128 ll;
const int M=;
const int mod=1e9+;
ll dp[M][M];
int a[M];
int n; inline ll read() {
ll x = , f = ;
char c = getchar();
for (; !isdigit(c);c = getchar()) if (c == '-') f = -;
for (; isdigit(c); c = getchar()) x = x * + c - '';
return x * f;
}
ll dfs1(int pos,int up){
if(pos==n+)
return ;
if(~dp[pos][up])
return dp[pos][up];
ll sum=;
for(int i=;i<=up;i++){
sum+=dfs1(pos+,max(up,i+));
}
dp[pos][up]=sum;
return sum;
}
void dfs2(int pos,int up,ll r){
if(pos==n+){
for(int i=;i<=n;i++)
putchar(a[i]+'A');
puts("");
return ;
}
for(int i=;i<=up;i++){
int nowup=max(i+,up);
if(r<=dp[pos+][nowup]){
a[pos]=i;
dfs2(pos+,nowup,r);
break;
}
else
r-=dp[pos+][nowup];
}
}
int main(){
int t;
scanf("%d",&t);
for(int ca=;ca<=t;ca++){
scanf("%d",&n);
ll k=read();
for(int i=;i<M;i++)
for(int j=;j<M;j++)
dp[i][j]=-;
for(int i=;i<M;i++)
dp[n+][i]=;
// cout<<"!!"<<endl;
dfs1(,);
printf("Case #%d: ",ca);
dfs2(,,k);
}
return ;
}

F. Rhyme scheme的更多相关文章

  1. 2019上海网络赛 F. Rhyme scheme 普通dp

    Rhyme scheme Problem Describe A rhyme scheme is the pattern of rhymes at the end of each line of a p ...

  2. The Preliminary Contest for ICPC Asia Shanghai 2019 F. Rhyme scheme(dp)

     题意:给你一个n和k 要你找到长度为n 字典序第k小的字符串 定义一个字符串合法:第i的字符的范围只能是前i-1个字符中的最大值+1 思路:我们dp[n][i][j]表示长度为n 在第i位 最大值为 ...

  3. 2019 上海网络赛 F Rhyme scheme (字典树DP)

    题目:https://nanti.jisuanke.com/t/41414 题意:求长度为n的第k个bell number  ,  就是第i位的选取范围在 1-(i-1)位的最大值 +1,第一位固定为 ...

  4. [2019上海网络赛F题]Rhyme scheme

    题目链接 题意,求出合法的长度为n的字典序第k小字符串,合法的定义为除了最后一位,每一位的取值范围为'A'到'A'+pos-1,而最后一位的取值范围'A'到当前字符串最大值+1. 队友tql,Orz ...

  5. The Preliminary Contest for ICPC Asia Shanghai 2019

    传送门 B. Light bulbs 题意: 起初\(n\)个位置状态为\(0\),\(m\)次操作,每次操作更换区间状态:\(0\)到\(1\),\(1\)到\(0\). 共有\(T,T\leq 1 ...

  6. POJ1671 Rhyme Schemes

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1776   Accepted: 984   Special Judge De ...

  7. scheme一页纸教程

    这是一个大学教授写的,非常好,原文:http://classes.soe.ucsc.edu/cmps112/Spring03/languages/scheme/SchemeTutorialA.html ...

  8. 算法语言Scheme修订6报告 R6RS简体中文翻译

    算法语言Scheme修订6报告 R6RS简体中文翻译 来源 https://r6rs.mrliu.org/   MICHAEL SPERBERR. KENT DYBVIG, MATTHEW FLATT ...

  9. Oracle导出excel

    oracle导出excel(非csv)的方法有两种,1.使用sqlplus  spool,2.使用包体 现将网上相关代码整理后贴出以备不时之需: 使用sqlplus: 使用sqlplus需要两个文件: ...

随机推荐

  1. PAT 2018 春

    A 1140 Look-and-say Sequence 简单模拟.可能要注意字符串第一个字符和最后一个字符的处理. #include <cstdio> #include <iost ...

  2. delphi 串口的打开与关闭

    Delphi 打开串口与关闭串口 procedure TForm1.btn1Click(Sender: TObject); begin cm1.CommName:=cbb1.Text; cm1.Bau ...

  3. POJ 3784 Running Median【维护动态中位数】

    Description For this problem, you will write a program that reads in a sequence of 32-bit signed int ...

  4. 牛客小白月赛18——Forsaken的三维数点

    这个是一个简单题,不过因为想到比标程时间复杂度更低的方法就尝试了一下. 思路:虽然加点是三维数点,但是我们要求的是半径的大小,这样的话,就可以转变为一维的问题. 标程的解法是,用树状数组维护,然后二分 ...

  5. 两个exe共享内存数据

    unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  6. one_day_one_linuxCmd---tar命令

    <坚持每天学习一个 linux 命令,今天我们来学习 tar 命令> 摘要:tar 命令是一个 Linux 下的打包程序,通常在 Linux 下,打包和压缩是不同的程序,打包通过 tar ...

  7. ZJNU 2342 - 夏华献要回家

    (夏华献在学校也要做一次梦!) 把5的答案手动算出 会发现从学校开始,兔子的数量呈斐波那契数列(第2项开始)增长 假如现在有n盏路灯 那么睡觉的时间可以得到为 但是n有1e18大,明显使用标准数学公式 ...

  8. SpringBoot+SpringSecurity+jwt整合及初体验

    原来一直使用shiro做安全框架,配置起来相当方便,正好有机会接触下SpringSecurity,学习下这个.顺道结合下jwt,把安全信息管理的问题扔给客户端, 准备 首先用的是SpringBoot, ...

  9. Linux(CENTOS7) Redis安装

    1.下载redis         在disk目录下,输入以下命令进行下载: wget http://download.redis.io/releases/redis-2.8.3.tar.gz 2.解 ...

  10. python3 str.encode bytes.decode

    str.encode 把字符串编码成字节序列 bytes.decode 把字节序列解码成字符串 https://docs.python.org/3.5/library/stdtypes.html st ...