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. Get Error when restoring database in Sql Server 2008 R2

         When I restored a database I got an error: "The backup set holds a backup of a database ot ...

  2. unresolved symbol @__security_check_cookie 解决方法

    ntstrsafe.lib(output.obj) : error LNK2019: unresolved external symbol @__security_check_cookie@4 ref ...

  3. CTS测试笔记

    电脑安装12.4乌班图系统 更新源 (1) 打开ubuntu software center (2) 电脑左上角选择edit→software sources…→点击download from,选择o ...

  4. packstack安装ironic

    KVM Centos7.3虚机 安装openstack Pike版本, 其它版本安装方法类似. packstack目前对NetworkManager 还不支持,我们修改下配置: systemctl d ...

  5. 数据挖掘算法:k-means算法的C++实现

    (期末考试要到了,所以比较粗糙,请各位读者理解..) 一.    概念 k-means是基于原型的.划分的聚类技术.它试图发现用户指定个数(K)的簇(由质心代表).K-means算法接受输入量K,然后 ...

  6. HDU 4588 Count The Carries(数学统计)

    Description One day, Implus gets interested in binary addition and binary carry. He will transfer al ...

  7. 编程练习:寻找发帖"水王"扩展问题一

    回顾 寻找发帖水王的问题总结起来就是在一个数组中某一个元素出现次数超过了数组长度的一半,那么可以很顺利的找到这个元素,实现见"编程练习:寻找发帖水王" 扩展 上面的问题中,强调了某 ...

  8. HTML5<canvas>标签:使用canvas元素在网页上绘制渐变和图像(2)

    详细解释HTML5 Canvas中渐进填充的参数设置与使用,Canvas中透明度的设置与使用,结合渐进填充与透明度支持,实现图像的Mask效果. 一:渐进填充(Gradient Fill) Canva ...

  9. 高中信息技术《算法与程序设计VB(选修)》知识要点

    原博主: http://blog.sina.com.cn/buyanshibai [转载] (一)算法 1.定义 相关题解: 1算法:就是解决问题的方法和步骤.算法是程序设计的“灵魂”,算法+数据结构 ...

  10. [bzoj] 1257 余数之和sum || 数论

    原题 给出正整数n和k,计算j(n, k)=k mod 1 + k mod 2 + k mod 3 + - + k mod n的值,其中k mod i表示k除以i的余数. \(\sum^n_{i=1} ...