v 0. Pasted by slipstak2 as cpp at 2011-02-11 19:01:05 MSK and set expiration to never.
v 1. Edited by MBZClkwbzuDDJiFpmQ as cpp at 2013-09-21 01:30:31 MSK and set expiration to 2013-09-21 02:30:31 MSK.
v 2. Edited by Anonymous as cpp at 2013-09-21 01:30:32 MSK and set expiration to never.
v 3. Edited by ZUJKwigjciLFX as cpp at 2014-02-14 15:54:28 MSK and set expiration to 2014-02-15 03:54:28 MSK.
v 4. Edited by Anonymous as cpp at 2014-02-14 15:54:36 MSK and set expiration to never.
v 5. Edited by PJFvpgUPprVi as cpp at 2014-02-17 18:47:48 MSK and set expiration to 2014-02-17 19:47:48 MSK.
v 6. Edited by Anonymous as cpp at 2014-02-17 18:47:50 MSK and set expiration to never.
v 7. Edited by Anonymous as cpp at 2014-02-28 06:56:18 MSK and set expiration to 2014-02-28 07:56:18 MSK.
v 8. Edited by Anonymous as cpp at 2014-02-28 06:56:20 MSK and set expiration to never.
v 9. Edited by NY as cpp at 2014-03-01 02:46:53 MSK and set expiration to 2014-03-01 08:46:53 MSK.
v 10. Edited by Anonymous as cpp at 2014-03-01 02:46:57 MSK and set expiration to never.
v 11. Edited by Anonymous as cpp at 2014-03-02 00:38:49 MSK and set expiration to 2014-03-02 06:38:49 MSK.
v 12. Edited by Anonymous as cpp at 2014-03-02 01:32:45 MSK and set expiration to 2014-03-02 07:32:45 MSK.
v 13. Edited by Anonymous as cpp at 2014-03-02 01:32:48 MSK and set expiration to never.
v 14. Edited by Anonymous as cpp at 2014-03-02 04:10:51 MSK and set expiration to 2014-03-02 10:10:51 MSK.
v 15. Edited by Anonymous as cpp at 2014-03-02 04:10:55 MSK and set expiration to never.
v 16. Edited by Anonymous as cpp at 2014-03-02 04:44:59 MSK and set expiration to 2014-03-02 16:44:59 MSK.
v 17. Edited by Anonymous as cpp at 2014-03-02 04:45:02 MSK and set expiration to never.
v 18. Edited by Anonymous as cpp at 2014-03-02 07:07:54 MSK and set expiration to 2014-03-03 07:07:54 MSK.
v 19. Edited by Anonymous as cpp at 2014-03-02 07:07:55 MSK and set expiration to never.
v 20. Edited by Anonymous as cpp at 2014-03-02 08:03:29 MSK and set expiration to 2014-03-02 20:03:29 MSK.
v 21. Edited by Anonymous as cpp at 2014-03-02 08:03:34 MSK and set expiration to never.
v 22. Edited by Anonymous as cpp at 2014-03-02 10:19:36 MSK and set expiration to 2014-03-02 16:19:36 MSK.
v 23. Edited by Anonymous as cpp at 2014-03-02 10:19:41 MSK and set expiration to never.
v 24. Edited by Anonymous as cpp at 2014-03-02 11:10:44 MSK and set expiration to 2014-03-02 23:10:44 MSK.
v 25. Edited by Anonymous as cpp at 2014-03-02 11:10:47 MSK and set expiration to never.
v 26. Edited by Anonymous as cpp at 2014-03-02 13:30:42 MSK and set expiration to 2014-03-02 14:30:42 MSK.
v 27. Edited by Anonymous as cpp at 2014-03-02 14:19:49 MSK and set expiration to 2014-03-02 20:19:49 MSK.
v 28. Edited by Anonymous as cpp at 2014-03-02 14:19:54 MSK and set expiration to never.
v 29. Edited by Anonymous as cpp at 2014-03-02 16:31:07 MSK and set expiration to 2014-03-03 16:31:07 MSK.
v 30. Edited by Anonymous as cpp at 2014-03-02 17:19:11 MSK and set expiration to 2014-03-03 17:19:11 MSK.
v 31. Edited by Anonymous as cpp at 2014-03-02 17:19:20 MSK and set expiration to never.
v 32. Edited by Anonymous as cpp at 2014-03-02 17:50:06 MSK and set expiration to 2014-03-02 23:50:06 MSK.
v 33. Edited by Anonymous as cpp at 2014-03-02 18:51:27 MSK and set expiration to 2014-03-02 19:51:27 MSK.
v 34. Edited by Anonymous as cpp at 2014-03-02 18:52:18 MSK and set expiration to never.
v 35. Edited by Anonymous as cpp at 2014-03-02 19:30:09 MSK and set expiration to 2014-03-03 19:30:09 MSK.
v 36. Edited by Anonymous as cpp at 2014-03-02 20:20:14 MSK and set expiration to 2014-03-03 02:20:14 MSK.
v 37. Edited by Anonymous as cpp at 2014-03-02 20:20:18 MSK and set expiration to never.
v 38. Edited by NY as cpp at 2014-03-02 21:12:28 MSK and set expiration to 2014-03-02 22:12:28 MSK.
v 39. Edited by Anonymous as cpp at 2014-03-02 21:19:36 MSK and set expiration to 2014-03-02 22:19:36 MSK.
v 40. Edited by Anonymous as cpp at 2014-03-02 21:19:36 MSK and set expiration to never.
v 41. Edited by Anonymous as cpp at 2014-03-02 22:22:36 MSK and set expiration to 2014-03-03 22:22:36 MSK.
v 42. Edited by Anonymous as cpp at 2014-03-02 22:22:40 MSK and set expiration to never.
v 43. Edited by Anonymous as cpp at 2014-03-02 22:33:42 MSK and set expiration to 2014-03-03 10:33:42 MSK.
v 44. Edited by Anonymous as cpp at 2014-03-02 22:33:44 MSK and set expiration to never.
v 45. Edited by Anonymous as cpp at 2014-03-02 23:28:32 MSK and set expiration to 2014-03-03 05:28:32 MSK.
v 46. Edited by Anonymous as cpp at 2014-03-02 23:28:34 MSK and set expiration to never.
v 47. Edited by Anonymous as cpp at 2014-03-03 00:47:55 MSK and set expiration to 2014-03-03 06:47:55 MSK.
v 48. Edited by Anonymous as cpp at 2014-03-03 00:47:56 MSK and set expiration to never.
v 49. Edited by Anonymous as cpp at 2014-03-03 01:44:32 MSK and set expiration to 2014-03-03 13:44:32 MSK.
v 50. Edited by Anonymous as cpp at 2014-03-03 01:51:14 MSK and set expiration to 2014-03-03 07:51:14 MSK.
v 51. Edited by Anonymous as cpp at 2014-03-03 01:51:17 MSK and set expiration to never.
v 52. Edited by Anonymous as cpp at 2014-03-03 02:36:25 MSK and set expiration to 2014-03-03 08:36:25 MSK.
v 53. Edited by Anonymous as cpp at 2014-03-03 02:36:30 MSK and set expiration to never.
v 54. Edited by Anonymous as cpp at 2014-03-03 04:14:51 MSK and set expiration to 2014-03-04 04:14:51 MSK.
v 55. Edited by Anonymous as cpp at 2014-03-03 04:14:52 MSK and set expiration to never.
v 56. Edited by Anonymous as cpp at 2014-03-03 04:53:16 MSK and set expiration to 2014-03-03 10:53:16 MSK.
v 57. Edited by Anonymous as cpp at 2014-03-03 04:54:41 MSK and set expiration to never.
v 58. Edited by Anonymous as cpp at 2014-03-03 05:15:30 MSK and set expiration to 2014-03-03 17:15:30 MSK.
v 59. Edited by Anonymous as cpp at 2014-03-03 05:15:33 MSK and set expiration to never.
v 60. Edited by Anonymous as cpp at 2014-03-03 07:57:21 MSK and set expiration to 2014-03-03 19:57:21 MSK.
v 61. Edited by Anonymous as cpp at 2014-03-03 08:06:00 MSK and set expiration to 2014-03-03 20:06:00 MSK.
v 62. Edited by Anonymous as cpp at 2014-03-03 08:07:00 MSK and set expiration to never.
v 63. Edited by Anonymous as cpp at 2014-03-03 08:45:03 MSK and set expiration to 2014-03-03 20:45:03 MSK.
v 64. Edited by Anonymous as cpp at 2014-03-03 08:45:07 MSK and set expiration to never.
v 65. Edited by Anonymous as cpp at 2014-03-03 09:03:47 MSK and set expiration to 2014-03-04 09:03:47 MSK.
v 66. Edited by Anonymous as cpp at 2014-03-03 09:03:51 MSK and set expiration to never.
v 67. Edited by Anonymous as cpp at 2014-03-03 10:13:52 MSK and set expiration to 2014-03-03 16:13:52 MSK.
v 68. Edited by Anonymous as cpp at 2014-03-03 11:04:20 MSK and set expiration to 2014-03-03 12:04:20 MSK.
v 69. Edited by Anonymous as cpp at 2014-03-03 11:04:27 MSK and set expiration to never.
v 70. Edited by Anonymous as cpp at 2014-03-03 11:39:15 MSK and set expiration to 2014-03-04 11:39:15 MSK.
v 71. Edited by Anonymous as cpp at 2014-03-03 11:49:41 MSK and set expiration to 2014-03-04 11:49:41 MSK.
v 72. Edited by Anonymous as cpp at 2014-03-03 12:42:37 MSK and set expiration to 2014-03-04 12:42:37 MSK.
v 73. Edited by Anonymous as cpp at 2014-03-03 12:42:41 MSK and set expiration to never.
v 74. Edited by Anonymous as cpp at 2014-03-03 12:54:24 MSK and set expiration to 2014-03-03 18:54:24 MSK.
v 75. Edited by Anonymous as cpp at 2014-03-03 12:54:25 MSK and set expiration to never.
v 76. Edited by Anonymous as cpp at 2014-03-03 14:21:57 MSK and set expiration to 2014-03-03 15:21:57 MSK.
v 77. Edited by Anonymous as cpp at 2014-03-03 14:22:01 MSK and set expiration to never.
v 78. Edited by Anonymous as cpp at 2014-03-03 15:16:33 MSK and set expiration to 2014-03-04 03:16:33 MSK.
v 79. Edited by Anonymous as cpp at 2014-03-03 15:38:26 MSK and set expiration to 2014-03-04 03:38:26 MSK.
v 80. Edited by Anonymous as cpp at 2014-03-03 16:27:56 MSK and set expiration to 2014-03-03 22:27:56 MSK.
v 81. Edited by Anonymous as cpp at 2014-03-03 16:28:00 MSK and set expiration to never.
v 82. Edited by Anonymous as cpp at 2014-03-03 16:36:05 MSK and set expiration to 2014-03-04 04:36:05 MSK.
v 83. Edited by Anonymous as cpp at 2014-03-03 16:36:09 MSK and set expiration to never.
v 84. Edited by Anonymous as cpp at 2014-03-03 16:42:36 MSK and set expiration to 2014-03-03 17:42:36 MSK.
v 85. Edited by Anonymous as cpp at 2014-03-03 17:33:47 MSK and set expiration to 2014-03-04 17:33:47 MSK.
v 86. Edited by Anonymous as cpp at 2014-03-03 17:33:52 MSK and set expiration to never.
v 87. Edited by Anonymous as cpp at 2014-03-03 19:16:53 MSK and set expiration to 2014-03-04 07:16:53 MSK.
v 88. Edited by Anonymous as cpp at 2014-03-03 19:58:36 MSK and set expiration to 2014-03-04 07:58:36 MSK.
v 89. Edited by Anonymous as cpp at 2014-03-03 20:00:38 MSK and set expiration to 2014-03-03 21:00:38 MSK.
v 90. Edited by Anonymous as cpp at 2014-03-03 20:00:41 MSK and set expiration to never.
v 91. Edited by Anonymous as cpp at 2014-03-03 20:20:17 MSK and set expiration to 2014-03-04 20:20:17 MSK.
v 92. Edited by Anonymous as cpp at 2014-03-03 20:20:23 MSK and set expiration to never.
v 93. Edited by Anonymous as cpp at 2014-03-03 20:39:39 MSK and set expiration to 2014-03-04 20:39:39 MSK.
v 94. Edited by Anonymous as cpp at 2014-03-03 20:39:43 MSK and set expiration to never.
v 95. Edited by Anonymous as cpp at 2014-03-03 21:06:25 MSK and set expiration to 2014-03-04 21:06:25 MSK.
v 96. Edited by Anonymous as cpp at 2014-03-03 21:06:26 MSK and set expiration to never.
v 97. Edited by Anonymous as cpp at 2014-03-03 22:21:48 MSK and set expiration to 2014-03-04 04:21:48 MSK.
v 98. Edited by Anonymous as cpp at 2014-03-03 22:45:59 MSK and set expiration to 2014-03-03 23:45:59 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-03 22:54:08 MSK and set expiration to 2014-03-04 10:54:08 MSK.
v 97. Edited by Anonymous as cpp at 2014-03-04 10:56:44 MSK and set expiration to 2014-03-04 11:56:44 MSK.
v 98. Edited by Anonymous as cpp at 2014-03-04 10:56:47 MSK and set expiration to never.
v 99. Edited by Anonymous as cpp at 2014-03-04 11:32:11 MSK and set expiration to 2014-03-04 23:32:11 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-04 23:33:44 MSK and set expiration to 2014-03-05 00:33:44 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-05 00:49:59 MSK and set expiration to 2014-03-06 00:49:59 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-06 03:31:15 MSK and set expiration to 2014-03-06 09:31:15 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-06 03:31:15 MSK and set expiration to 2014-03-06 09:31:15 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-06 19:24:30 MSK and set expiration to 2014-03-07 01:24:30 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-07 01:51:26 MSK and set expiration to 2014-03-07 13:51:26 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-07 14:47:02 MSK and set expiration to 2014-03-07 20:47:02 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-07 21:16:26 MSK and set expiration to 2014-03-08 03:16:26 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-08 03:47:11 MSK and set expiration to 2014-03-08 15:47:11 MSK.
v 99. Edited by NY as cpp at 2014-03-08 17:22:19 MSK and set expiration to 2014-03-08 23:22:19 MSK.
v 99. Edited by NY as cpp at 2014-03-09 00:28:16 MSK and set expiration to 2014-03-09 06:28:16 MSK.
v 99. Edited by NY as cpp at 2014-03-09 11:32:15 MSK and set expiration to 2014-03-09 12:32:15 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-09 21:26:31 MSK and set expiration to 2014-03-10 03:26:31 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-10 03:48:55 MSK and set expiration to 2014-03-10 09:48:55 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-10 10:09:05 MSK and set expiration to 2014-03-10 11:09:05 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-10 14:12:00 MSK and set expiration to 2014-03-11 02:12:00 MSK.
v 99. Edited by NY as cpp at 2014-03-11 02:28:28 MSK and set expiration to 2014-03-11 03:28:28 MSK.
v 99. Edited by NY as cpp at 2014-03-11 05:01:58 MSK and set expiration to 2014-03-12 05:01:58 MSK.
v 99. Edited by NY as cpp at 2014-03-12 05:39:55 MSK and set expiration to 2014-03-12 11:39:55 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-12 14:16:46 MSK and set expiration to 2014-03-13 14:16:46 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-13 21:04:11 MSK and set expiration to 2014-03-13 22:04:11 MSK.
v 99. Edited by Anonymous as cpp at 2014-03-14 01:07:15 MSK and set expiration to 2014-03-15 01:07:15 MSK.
v 99. Edited by NY as cpp at 2014-03-15 01:51:06 MSK and set expiration to 2014-03-16 01:51:06 MSK.
v 99. Edited by NY as cpp at 2014-03-16 03:12:06 MSK and set expiration to 2014-03-16 09:12:06 MSK.
v 99. Edited by NY as cpp at 2014-03-16 19:21:53 MSK and set expiration to 2014-03-17 07:21:53 MSK.
v 99. Edited by NY as cpp at 2014-03-17 21:22:14 MSK and set expiration to 2014-03-17 22:22:14 MSK.
v 99. Edited by NY as cpp at 2014-03-18 08:33:32 MSK and set expiration to 2014-03-18 20:33:32 MSK.
v 99. Edited by NY as cpp at 2014-03-18 23:59:16 MSK and set expiration to 2014-03-19 11:59:16 MSK.
v 99. Edited by qeNsOcLjHE as cpp at 2014-03-19 15:35:22 MSK and set expiration to 2014-03-19 21:35:22 MSK.
v 99. Edited by RltjfJZmBSUXYWXpWj as cpp at 2014-03-19 21:46:31 MSK and set expiration to 2014-03-20 09:46:31 MSK.
v 99. Edited by NY as cpp at 2014-03-20 10:14:11 MSK and set expiration to 2014-03-20 11:14:11 MSK.
v 99. Edited by NY as cpp at 2014-03-21 09:07:23 MSK and set expiration to 2014-03-21 10:07:23 MSK.
v 99. Edited by NY as cpp at 2014-03-21 10:43:09 MSK and set expiration to 2014-03-22 10:43:09 MSK.
v 99. Edited by NY as cpp at 2014-03-22 17:01:23 MSK and set expiration to 2014-03-22 23:01:23 MSK.
v 99. Edited by NY as cpp at 2014-03-23 07:12:35 MSK and set expiration to 2014-03-23 19:12:35 MSK.
v 99. Edited by NY as cpp at 2014-03-25 22:06:27 MSK and set expiration to 2014-03-26 04:06:27 MSK.
v 99. Edited by NY as cpp at 2014-03-29 18:11:39 MSK and set expiration to 2014-03-30 06:11:39 MSK.
v 99. Edited by NY as cpp at 2014-03-31 06:31:57 MSK and set expiration to 2014-04-01 06:31:57 MSK.
v 99. Edited by NY as cpp at 2014-05-21 22:45:00 MSK and set expiration to 2014-05-21 23:45:00 MSK.
v 99. Edited by Anonymous as cpp at 2014-07-04 11:10:46 MSK and set expiration to 2014-07-04 12:10:46 MSK.
v 99. Edited by jywipqd as cpp at 2014-09-08 20:41:45 MSK and set expiration to 2014-09-09 02:41:45 MSK.
v 99. Edited by vyeffhwz as cpp at 2014-09-20 20:00:10 MSK and set expiration to 2014-09-21 02:00:10 MSK.
v 99. Edited by vqJsFIQhvQt as cpp at 2014-10-21 00:33:38 MSK and set expiration to 2014-10-21 01:33:38 MSK.
v 99. Edited by sFhxMZYrfWC as cpp at 2014-11-06 12:25:09 MSK and set expiration to 2014-11-06 18:25:09 MSK.
v 99. Edited by UfjFRAoGGuELu as cpp at 2014-11-06 21:16:43 MSK and set expiration to 2014-11-07 03:16:43 MSK.
v 99. Edited by MDbPUkYlvz as cpp at 2014-11-07 05:42:22 MSK and set expiration to 2014-11-07 11:42:22 MSK.
v 99. Edited by ctHVfLSNSLYdgaN as cpp at 2014-11-07 12:02:48 MSK and set expiration to 2014-11-07 18:02:48 MSK.
v 99. Edited by fCAOuOaKvUgs as cpp at 2014-11-07 19:41:29 MSK and set expiration to 2014-11-07 20:41:29 MSK.
v 99. Edited by FXKykaIbgGuHNU as cpp at 2014-11-08 12:07:31 MSK and set expiration to 2014-11-09 00:07:31 MSK.
v 99. Edited by FXFurYOdUDIbhymJ as cpp at 2014-11-09 08:26:55 MSK and set expiration to 2014-11-10 08:26:55 MSK.
v 99. Edited by NiHpNjWn as cpp at 2014-11-10 08:48:34 MSK and set expiration to 2014-11-10 20:48:34 MSK.
v 99. Edited by xirqkRgETuriTlGUgMD as cpp at 2014-11-11 01:31:42 MSK and set expiration to 2014-11-11 07:31:42 MSK.
v 99. Edited by algakDoHqPNur as cpp at 2014-11-12 01:43:48 MSK and set expiration to 2014-11-12 02:43:48 MSK.
v 99. Edited by oxZjVTcEhIOnApyU as cpp at 2014-11-12 05:51:40 MSK and set expiration to 2014-11-12 06:51:40 MSK.
v 99. Edited by PiYDQVjVOjni as cpp at 2014-11-12 08:54:56 MSK and set expiration to 2014-11-12 09:54:56 MSK.
v 99. Edited by TrCnuifH as cpp at 2014-11-12 11:49:03 MSK and set expiration to 2014-11-12 23:49:03 MSK.
v 99. Edited by uTsgBKFXD as cpp at 2014-11-13 01:57:43 MSK and set expiration to 2014-11-13 13:57:43 MSK.
v 99. Edited by KqhkfNmprwCrEonyIat as cpp at 2014-11-16 06:28:43 MSK and set expiration to 2014-11-16 12:28:43 MSK.
v 99. Edited by WSGfShznRZxLdJJZ as cpp at 2014-11-17 18:53:54 MSK and set expiration to 2014-11-17 19:53:54 MSK.
v 99. Edited by koSYJNoLcrvoQfF as cpp at 2014-12-20 02:39:48 MSK and set expiration to 2014-12-21 02:39:48 MSK.
v 99. Edited by zeTkhGMTaRjkIuFelYY as cpp at 2014-12-21 22:30:26 MSK and set expiration to 2014-12-22 04:30:26 MSK.
v 99. Edited by qjpprpcYHVgX as cpp at 2015-01-03 10:38:42 MSK and set expiration to 2015-01-03 22:38:42 MSK.
v 99. Edited by YtohrUiNW as cpp at 2015-01-05 22:27:55 MSK and set expiration to 2015-01-06 04:27:55 MSK.
v 99. Edited by NY as cpp at 2015-01-09 11:32:57 MSK and set expiration to 2015-01-09 12:32:57 MSK.
v 99. Edited by NY as cpp at 2015-01-12 07:39:56 MSK and set expiration to 2015-01-13 07:39:56 MSK.
v 100. Reverted by asasas to version 0 at 2015-01-12 15:57:07 MSK.

Paste will expire never.

  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4.  
  5. using namespace std;
  6.  
  7. int fact[13] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600};
  8. int notUsed(vector<bool> &used, int blockNum) {
  9.  
  10.     int j=0, pos = 0;
  11.     for (j = 1; j < used.size(); j++) {
  12.         if (!used[j]) pos++;
  13.         if (blockNum == pos)
  14.             break;
  15.     }
  16.     return j;
  17. }
  18. int getBlockNum(vector<bool> &used, int value) {
  19.     int blockNum = 0;
  20.     for (int i=1;i<used.size();i++) {
  21.         if (!used[i]) {
  22.             blockNum++;
  23.             if (i == value)
  24.                 break;
  25.         }
  26.     }
  27.     return blockNum;
  28. }
  29. vector<int> permutation_by_num(int n, int num) {
  30.  
  31.     vector<int> res(n);
  32.     vector<bool> used(n+1,false);
  33.  
  34.     for (int i = 0; i < n; i++) {
  35.         int blockNum = (num - 1) / fact[n - i - 1] + 1;
  36.         int j = notUsed(used, blockNum);
  37.         res[i] = j;
  38.         used[j] = true;
  39.         num = (num - 1) % fact[n - i - 1] + 1;
  40.     }
  41.     return res;
  42. }
  43. int num_by_permutation(vector<int> &perm) {
  44.     int n = perm.size();
  45.     vector<bool> used(n+1,false);
  46.  
  47.     int num = 1;
  48.     for (int i = 0; i < n; i++) {
  49.         int blockNum = getBlockNum(used,perm[i]);
  50.         num += (blockNum - 1) * fact[n - 1 - i];
  51.         used[perm[i]] = true;
  52.     }
  53.     return num;
  54. }
  55. void output(vector<int> &perm) {
  56.     for (int i=0;i<perm.size();i++)
  57.         cout<<perm[i]<<' ';
  58. }
  59. int main() {
  60.     freopen("input.txt","r",stdin);
  61.     freopen("output.txt","w",stdout);
  62.  
  63.     int n,num;
  64.     cin>>n>>num;
  65.     vector<int> perm = permutation_by_num(n,num);
  66.     if (num_by_permutation(perm) != num)
  67.         while(true) {};
  68.     output(perm);
  69.     return 0;
  70. }