Skip to content

Commit

Permalink
24
Browse files Browse the repository at this point in the history
  • Loading branch information
faithByte committed May 31, 2023
1 parent ebc833f commit 50d020d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
38 changes: 38 additions & 0 deletions #024:Lexicographic_permutations.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

typedef unsigned long long ull ;
// # define fract13 6227020800
# define X 479001600 // 13! / 13

int main() {
ull n, x, k;
short q, size;
vector<char> v = {'a', 'b', 'c', 'd', 'e', 'f', 'j', 'h', 'j', 'k', 'l', 'm'}, tmp;

cin >> q;
for (short i = 0; i < q; i++)
{
cin >> n;
n--;
tmp = v;
x = X;
size = 13;
while (size)
{
k = (n / x);
cout << tmp[k];
tmp.erase(tmp.begin() + k);
n -= (n / x) * x;
--size;
x /= size;
}
cout << endl;
tmp.clear();
}
return 0;
}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,7 @@ ___

[Hackerrank] Given N, print YES if it can be expressed as sum of two abundant numbers, else print NO.

[projecteuler] Find the sum of all positive integers that cannot be written as the sum of two abundant numbers.
[projecteuler] Find the sum of all positive integers that cannot be written as the sum of two abundant numbers.
___
## <a href=https://www.hackerrank.com/contests/projecteuler/challenges/euler024/problem?isFullScreen> Problem 24: </a> Lexicographic permutations <sup>[Easy]</sup>
What is the N<sup>th</sup> lexicographic permutation of the word "abcdefghijklm".

0 comments on commit 50d020d

Please sign in to comment.