标签:
逆康拓展开应用
/************************************************************************* > File Name: nyoj143.cpp > Author: ALex > Mail: 405045132@qq.com > Created Time: 2015年01月12日 星期一 21时47分51秒 ************************************************************************/ #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int fn[14]; int ans[14]; bool vis[14]; int main() { fn[0] = 1; for (int i = 1; i <= 12; ++i) { fn[i] = fn[i - 1] * i; } int t; scanf("%d", &t); while (t--) { int k; memset (vis, 0, sizeof(vis)); scanf("%d", &k); k--; int cnt = 0, cur = 11; while (cur > 0) { int x = k / fn[cur]; k %= fn[cur]; cur--; for (int i = 1; i <= 12; ++i) { if (!vis[i]) { if (x == 0) { vis[i] = 1; ans[++cnt] = i; break; } --x; } } } for (int i = 1; i <= 12; ++i) { if (!vis[i]) { ans[++cnt] = i; break; } } for (int i = 1; i <= 12; ++i) { printf("%c", ans[i] - 1 + 'a'); } printf("\n"); } return 0; }
标签:
原文地址:http://blog.csdn.net/guard_mine/article/details/42651773