{"id":1415,"date":"2013-03-22T20:37:23","date_gmt":"2013-03-22T12:37:23","guid":{"rendered":"https:\/\/blog.rexdf.org\/?p=1415"},"modified":"2013-03-22T20:37:23","modified_gmt":"2013-03-22T12:37:23","slug":"codeforces-175-a","status":"publish","type":"post","link":"https:\/\/blog.rexdf.org\/en\/2013\/03\/codeforces-175-a\/","title":{"rendered":"Codeforces 175 A"},"content":{"rendered":"<p>&nbsp;<\/p>\n<div>\n<div>A. Slightly Decreasing Permutations<\/div>\n<div>\n<div>time limit per test<\/div>\n<p>2 seconds<\/p><\/div>\n<div>\n<div>memory limit per test<\/div>\n<p>256 megabytes<\/p><\/div>\n<div>\n<div>input<\/div>\n<p>standard input<\/p><\/div>\n<div>\n<div>output<\/div>\n<p>standard output<\/p><\/div>\n<\/div>\n<div>\n<p>Permutation\u00a0<i>p<\/i>\u00a0is an ordered set of integers\u00a0<i>p<\/i><sub>1<\/sub>,\u2009\u2009<i>p<\/i><sub>2<\/sub>,\u2009\u2009&#8230;,\u2009\u2009<i>p<\/i><sub><i>n<\/i><\/sub>, consisting of\u00a0<i>n<\/i>\u00a0distinct positive integers, each of them doesn&#8217;t exceed\u00a0<i>n<\/i>. We&#8217;ll denote the\u00a0<i>i<\/i>-th element of permutation\u00a0<i>p<\/i>\u00a0as\u00a0<i>p<\/i><sub><i>i<\/i><\/sub>. We&#8217;ll call number\u00a0<i>n<\/i>\u00a0the size or the length of permutation\u00a0<i>p<\/i><sub>1<\/sub>,\u2009\u2009<i>p<\/i><sub>2<\/sub>,\u2009\u2009&#8230;,\u2009\u2009<i>p<\/i><sub><i>n<\/i><\/sub>.<\/p>\n<p>The decreasing coefficient of permutation\u00a0<i>p<\/i><sub>1<\/sub>,\u2009<i>p<\/i><sub>2<\/sub>,\u2009&#8230;,\u2009<i>p<\/i><sub><i>n<\/i><\/sub>\u00a0is the number of such\u00a0<i>i<\/i>\u00a0(1\u2009\u2264\u2009<i>i<\/i>\u2009&lt;\u2009<i>n<\/i>), that\u00a0<i>p<\/i><sub><i>i<\/i><\/sub>\u2009&gt;\u2009<i>p<\/i><sub><i>i<\/i>\u2009+\u20091<\/sub>.<\/p>\n<p>You have numbers\u00a0<i>n<\/i>\u00a0and\u00a0<i>k<\/i>. Your task is to print the permutation of length\u00a0<i>n<\/i>\u00a0with decreasing coefficient\u00a0<i>k<\/i>.<\/p>\n<\/div>\n<div>\n<div>Input<\/div>\n<p>The single line contains two space-separated integers:\u00a0<i>n<\/i>,\u2009<i>k<\/i>\u00a0(1\u2009\u2264\u2009<i>n<\/i>\u2009\u2264\u200910<sup>5<\/sup>,\u20090\u2009\u2264\u2009<i>k<\/i>\u2009&lt;\u2009<i>n<\/i>)\u00a0\u2014 the permutation length and the decreasing coefficient.<\/p>\n<\/div>\n<div>\n<div>Output<\/div>\n<p>In a single line print\u00a0<i>n<\/i>\u00a0space-separated integers:\u00a0<i>p<\/i><sub>1<\/sub>,\u2009<i>p<\/i><sub>2<\/sub>,\u2009&#8230;,\u2009<i>p<\/i><sub><i>n<\/i><\/sub>\u00a0\u2014 the permutation of length\u00a0<i>n<\/i>\u00a0with decreasing coefficient\u00a0<i>k<\/i>.<\/p>\n<p>If there are several permutations that meet this condition, print any of them. It is guaranteed that the permutation with the sought parameters exists.<\/p>\n<\/div>\n<div>\n<div>Sample test(s)<\/div>\n<div>\n<div>\n<div>input<\/div>\n<pre>5 2<\/pre>\n<\/div>\n<div>\n<div>output<\/div>\n<pre>1 5 2 4 3<\/pre>\n<\/div>\n<div>\n<div>input<\/div>\n<pre>3 0<\/pre>\n<\/div>\n<div>\n<div>output<\/div>\n<pre>1 2 3<\/pre>\n<\/div>\n<div>\n<div>input<\/div>\n<pre>3 2<\/pre>\n<\/div>\n<div>\n<div>output<\/div>\n<pre>3 2 1<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<pre class=\"brush: cpp; gutter: true\">\r\n#include &lt;iostream&gt;\r\n#include &lt;cstdio&gt;\r\n#include &lt;cstring&gt;\r\n\r\nusing namespace std;\r\n\r\n\r\nint main()\r\n{\r\n    int n,k;\r\n    cin&gt;&gt;n&gt;&gt;k;\r\n    cout&lt;&lt;(k+1);\r\n    for(int i=k;i&gt;0;i--)\r\n      cout&lt;&lt;&quot; &quot;&lt;&lt;i;\r\n    for(int i=k+2;i&lt;=n;i++)\r\n      cout&lt;&lt;&quot; &quot;&lt;&lt;i;\r\n    cout&lt;&lt;endl;\r\n    return 0;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; A. Slightly Decreasing Permutations time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Permutation\u00a0p\u00a0is an ordered set of integers\u00a0p1,\u2009\u2009p2,\u2009\u2009&#8230;,\u2009\u2009pn, consisting of\u00a0n\u00a0distinct positive integers, each of them doesn&#8217;t exceed\u00a0n. We&#8217;ll denote &hellip; <a href=\"https:\/\/blog.rexdf.org\/en\/2013\/03\/codeforces-175-a\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[125],"class_list":["post-1415","post","type-post","status-publish","format-standard","hentry","category-algorithm","tag-codeforces"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.rexdf.org\/en\/wp-json\/wp\/v2\/posts\/1415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.rexdf.org\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.rexdf.org\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rexdf.org\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rexdf.org\/en\/wp-json\/wp\/v2\/comments?post=1415"}],"version-history":[{"count":0,"href":"https:\/\/blog.rexdf.org\/en\/wp-json\/wp\/v2\/posts\/1415\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.rexdf.org\/en\/wp-json\/wp\/v2\/media?parent=1415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.rexdf.org\/en\/wp-json\/wp\/v2\/categories?post=1415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.rexdf.org\/en\/wp-json\/wp\/v2\/tags?post=1415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}