Description

Corn does not participate the STEED contest, but he is interested in the word "STEED". So, Corn writes all permutations of the word "STEED" on different cards and gets 60 cards finally.

Corn sorts these cards in lexicographical order, and marks them from 1 to 60.

Now, Corn gives you a integer N (1 ≤ N ≤ 60), could you tell him the word on the Nth card?

Input

There are multiple test cases (no more than 60).

For each test case, there is one integer N (1 ≤ N ≤ 60) in a line.

Output

For each test case, you should output one line with the word on the Nth card.

Sample Input

1
2
3
4
47
48
49

Sample Output

DEEST
DEETS
DESET
DESTE
STEDE
STEED
TDEES

分析:

对DEEST这几个字符组成的字符串按照字典序排序,重复的字符串肯定是只按一个算的,然后输出n,输出第n个字符串。

代码:

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main()
{
char ch[10]= {'D','E','E','S','T'};
string str[150]= {"DEEST"}; ///首先肯定得有第一个才可以
int ans=0,n;
do
{
for(int i=0; i<5; i++)
{
str[ans][i]=ch[i];
}
ans++;
}
while(next_permutation(ch,ch+5));///直接用全排列函数先打表
while(~scanf("%d",&n))
{
cout<<str[n-1]<<endl;///直接输出来就行
}
return 0;
}

2017年上海金马五校程序设计竞赛:Problem A : STEED Cards (STL全排列函数)的更多相关文章

  1. 2017年上海金马五校程序设计竞赛:Problem K : Treasure Map (蛇形填数)

    Description There is a robot, its task is to bury treasures in order on a N × M grids map, and each ...

  2. 2017年上海金马五校程序设计竞赛:Problem I : Frog's Jumping (找规律)

    Description There are n lotus leaves floating like a ring on the lake, which are numbered 0, 1, ..., ...

  3. 2017年上海金马五校程序设计竞赛:Problem G : One for You (博弈)

    Description Given a m × n chessboard, a stone is put on the top-left corner (1, 1). Kevin and Bob ta ...

  4. 2017年上海金马五校程序设计竞赛:Problem E : Find Palindrome (字符串处理)

    Description Given a string S, which consists of lowercase characters, you need to find the longest p ...

  5. 2017年上海金马五校程序设计竞赛:Problem C : Count the Number (模拟)

    Description Given n numbers, your task is to insert '+' or '-' in front of each number to construct ...

  6. 2017年上海金马五校程序设计竞赛:Problem B : Sailing (广搜)

    Description Handoku is sailing on a lake at the North Pole. The lake can be considered as a two-dime ...

  7. 2017Summmer_上海金马五校 F题,G题,I题,K题,J题

    以下题目均自己搜 F题  A序列 一开始真的没懂题目什么意思,还以为是要连续的子串,结果发现时序列,简直智障,知道题意之后,好久没搞LIS,有点忘了,复习一波以后,直接双向LIS,处理处两个数组L和R ...

  8. HDU 5923 Prediction(2016 CCPC东北地区大学生程序设计竞赛 Problem B,并查集)

    题目链接  2016 CCPC东北地区大学生程序设计竞赛 B题 题意  给定一个无向图和一棵树,树上的每个结点对应无向图中的一条边,现在给出$q$个询问, 每次选定树中的一个点集,然后真正被选上的是这 ...

  9. “盛大游戏杯”第15届上海大学程序设计联赛夏季赛暨上海高校金马五校赛题解&&源码【A,水,B,水,C,水,D,快速幂,E,优先队列,F,暴力,G,贪心+排序,H,STL乱搞,I,尼姆博弈,J,差分dp,K,二分+排序,L,矩阵快速幂,M,线段树区间更新+Lazy思想,N,超级快速幂+扩展欧里几德,O,BFS】

    黑白图像直方图 发布时间: 2017年7月9日 18:30   最后更新: 2017年7月10日 21:08   时间限制: 1000ms   内存限制: 128M 描述 在一个矩形的灰度图像上,每个 ...

随机推荐

  1. redis学习资料汇总

    redis学习资料汇总 2017年01月07日 22:10:37 阅读数:281 转载:http://blog.csdn.net/wtyvhreal/article/details/50427627 ...

  2. spring location设置本地路径

    <context:property-placeholder location="file:D:/jdbc.properties"/> 直接在路径前加上 file:

  3. Qt 编译时遇到 error: [debug/qrc_music.cpp] Error 1

    第一种方式,清理编译文件 把Qdebug release 文件件都删除, 删除makefile 文件 尝试重新编译 以上是网上寻找的结果 以下是我的解决方法 如果还抱错,请检查qrc文件是否存在异常 ...

  4. 算法搬运之BFPRT算法

    原文连接:http://noalgo.info/466.html BFPRT算法,又称为中位数的中位数算法,由5位大牛(Blum . Floyd . Pratt . Rivest . Tarjan)提 ...

  5. Python 3基础教程30-sys模块

    本文介绍sys模块,简单打印两个重定向输出. 目前使用机会没有,以后实际用到了,再去研究和学习.

  6. javaX邮件发送

    /** * *  * @param mailServerHost 邮件服务器 * @param mailServerPort 端口 * @param validate 是否需要身份验证 * @para ...

  7. 【CodeForces】9A-Die Roll

    目录 Question Solution 解法1 解法2 Question 三个人掷骰子,前两个人的得分分别是Y和W,问第三个人胜利的概率(第三个人得分不小于Y.W)?结果输出格式为\(A/B\),如 ...

  8. LeetCode 36——有效的数独

    1. 题目 2. 解答 将数独中数字的 ASCII 码值转化到 0-8 之间作为散列值,建立一个散列表,然后分别逐行.逐列.逐宫(3*3小块)统计每个数字的出现次数,若出现次数大于 1,则数独无效. ...

  9. Elicpse新建userLibrary导入jar包时抛出NotFoundException异常

    最近刚开始学Struts2.0框架.再导入jar包的时候突然心血来潮.为方便区分jar包的功能,于是想在WEB-INF -> lib 目录下想新建一个struts文件夹,以方便分类查看. 像上图 ...

  10. PAT 甲级 1006 Sign In and Sign Out

    https://pintia.cn/problem-sets/994805342720868352/problems/994805516654460928 At the beginning of ev ...