{"id":620,"date":"2016-06-30T13:19:25","date_gmt":"2016-06-30T10:19:25","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=620"},"modified":"2016-07-05T07:57:45","modified_gmt":"2016-07-05T04:57:45","slug":"620","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=620","title":{"rendered":"e-olymp 126. \u041d\u043e\u043c\u0435\u0440 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b"},"content":{"rendered":"<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430.<\/strong> \u041c\u043d\u043e\u0433\u043e\u043a\u0432\u0430\u0440\u0442\u0438\u0440\u043d\u044b\u0439 \u0434\u043e\u043c \u0438\u043c\u0435\u0435\u0442 [latex]N[\/latex]\u00a0\u043a\u0432\u0430\u0440\u0442\u0438\u0440, [latex]P[\/latex]\u00a0\u043f\u043e\u0434\u044a\u0435\u0437\u0434\u043e\u0432 \u0438 [latex]Q[\/latex]\u00a0\u044d\u0442\u0430\u0436\u0435\u0439, \u043f\u0440\u0438\u0447\u0435\u043c \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u044d\u0442\u0430\u0436\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0435 \u0438 \u043d\u0430 \u043a\u0430\u043a\u043e\u043c \u044d\u0442\u0430\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u043c [latex]K[\/latex].<\/p>\n<h2>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0412 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0444\u0430\u0439\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f [latex]N, P, Q, K. 1 \\leq K \\leq N \\leq 1000, P \\times Q \\leq N.[\/latex]\n<h2>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0412 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0444\u0430\u0439\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0430 \u0438 \u044d\u0442\u0430\u0436, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430 \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c [latex]K.[\/latex]\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0432\u0437\u044f\u0442\u0430 \u0441 \u0441\u0430\u0439\u0442\u0430\u00a0<a href=\"http:\/\/www.e-olymp.com\/ru\/problems\/126\" target=\"_blank\">e \u2013 olymp.<\/a><\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<table width=\"320\">\n<tbody>\n<tr style=\"height: 24.2656px\">\n<td style=\"height: 24.2656px\">\u00a0 \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/td>\n<td style=\"height: 24.2656px\">\u00a0 \u00a0\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/td>\n<\/tr>\n<tr style=\"height: 24px\">\n<td style=\"height: 24px\">\u00a0 \u00a0 \u00a0 250 \u00a0 5 \u00a0 \u00a05 \u00a0 \u00a0 1<\/td>\n<td style=\"height: 24px\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a01 \u00a01<\/td>\n<\/tr>\n<tr style=\"height: 24px\">\n<td style=\"height: 24px\">\u00a0 \u00a0 \u00a0 \u00a0 30 \u00a0 2 \u00a0 \u00a05 \u00a0 \u00a0 27<\/td>\n<td style=\"height: 24px\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a02 \u00a04<\/td>\n<\/tr>\n<tr style=\"height: 24px\">\n<td style=\"height: 24px\">\u00a0 \u00a0 \u00a0 300 \u00a03 \u00a0 \u00a010 \u00a0 111<\/td>\n<td style=\"height: 24px\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a02 \u00a02<\/td>\n<\/tr>\n<tr style=\"height: 24px\">\n<td style=\"height: 24px\">\u00a0 \u00a0 \u00a0 \u00a0 80 \u00a05 \u00a0 \u00a0 4 \u00a0 \u00a0 77<\/td>\n<td style=\"height: 24px\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a05 \u00a04<\/td>\n<\/tr>\n<tr style=\"height: 24px\">\n<td style=\"height: 24px\">\u00a0 \u00a0 \u00a0 \u00a0 98 \u00a07 \u00a0 \u00a0 2 \u00a0 \u00a0 39<\/td>\n<td style=\"height: 24px\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a03 \u00a02<\/td>\n<\/tr>\n<tr style=\"height: 24px\">\n<td style=\"height: 24px\">\u00a0 \u00a0 \u00a0 \u00a0 90 \u00a03 \u00a0 \u00a0 15 \u00a0 90<\/td>\n<td style=\"height: 24px\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a03 \u00a015<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u041f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0431\u044b\u043b\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u0434\u043e\u043c\u0435 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u0432\u0430\u0440\u0442\u0438\u0440, \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u043e\u0432 \u0438 \u044d\u0442\u0430\u0436\u0435\u0439 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0430 \u0438 \u044d\u0442\u0430\u0436. \u0414\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0445\u043e\u0434\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c\u00a0\u0434\u0432\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u2013 <em>flatEntrance<\/em> (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0435) \u0438\u00a0<em>flatFloor<\/em> (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044d\u0442\u0430\u0436\u0435). \u041d\u0430\u0439\u0434\u0435\u043c\u00a0\u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0446\u0435\u043b\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0435. \u0414\u0430\u043b\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043e\u0441\u0442\u0430\u0442\u043a\u0430 \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043e\u043d \u043e\u0442\u043b\u0438\u0447\u0435\u043d \u043e\u0442 \u043d\u0443\u043b\u044f, \u0442\u043e \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0443\u0436\u0435 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0435. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <em>entrance<\/em>.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u044d\u0442\u0430\u0436\u0430 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0435 \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043b\u0438 \u043d\u043e\u043c\u0435\u0440 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0435 \u043d\u0430\u0446\u0435\u043b\u043e, \u0435\u0441\u043b\u0438 \u0434\u0430 \u2013 \u043e\u043d\u0430 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u044d\u0442\u0430\u0436\u0435. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0442\u043e \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c [latex]0[\/latex]. \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u043e\u043c\u0435\u0440 \u044d\u0442\u0430\u0436\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u043e\u0434\u0435\u043b\u0438\u0432 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440 \u0432 \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0435 \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440 \u043d\u0430 \u044d\u0442\u0430\u0436\u0435 (\u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u044a\u0435\u0437\u0434 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u0442\u0430\u0436\u0430). \u0418 \u0441\u043d\u043e\u0432\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043e\u0441\u0442\u0430\u0442\u043a\u0430 \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u041f\u0440\u0438 \u043d\u0430\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <em>floor<\/em>.<\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:<\/p>\n<pre class=\"lang:java decode:true \">import java.util.*;\r\nimport java.lang.*;\r\nimport java.io.*;\r\n\r\nclass Main\r\n{\r\n\tpublic static void main (String[] args) throws java.lang.Exception\r\n\t{\r\n\t\tint N, P, Q, K, flatEntrance, flatFloor, entrance, floor;\r\n\t\tScanner sc = new Scanner(System.in);\r\n\t\tN = sc.nextInt();\r\n\t\tP = sc.nextInt();\r\n\t\tQ = sc.nextInt();\r\n\t\tK = sc.nextInt();\r\n\t\tflatEntrance = N\/P;\r\n    \tflatFloor = N\/P\/Q;\r\n\t\tentrance = K\/flatEntrance; \r\n\t\tif (K%flatEntrance != 0){\r\n\t\t\tentrance++;\r\n\t\t}\r\n\t\tif (K%flatEntrance == 0){\r\n\t\t    floor = Q;\r\n\t\t}\r\n\t\telse {\r\n\t\t    floor = (K%flatEntrance)\/flatFloor; \r\n\t\t    if (K%flatFloor != 0){\r\n\t\t  \t    floor++;\r\n\t\t    }\r\n\t\t}\r\n\t\tSystem.out.format(\"%d %d\", entrance, floor);\r\n\t}\r\n}<\/pre>\n<p><a href=\"http:\/\/ideone.com\/UkWtE4\" target=\"_blank\">\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430. \u041c\u043d\u043e\u0433\u043e\u043a\u0432\u0430\u0440\u0442\u0438\u0440\u043d\u044b\u0439 \u0434\u043e\u043c \u0438\u043c\u0435\u0435\u0442 [latex]N[\/latex]\u00a0\u043a\u0432\u0430\u0440\u0442\u0438\u0440, [latex]P[\/latex]\u00a0\u043f\u043e\u0434\u044a\u0435\u0437\u0434\u043e\u0432 \u0438 [latex]Q[\/latex]\u00a0\u044d\u0442\u0430\u0436\u0435\u0439, \u043f\u0440\u0438\u0447\u0435\u043c \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u044d\u0442\u0430\u0436\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0432\u0430\u0440\u0442\u0438\u0440. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0435 \u0438 \u043d\u0430 \u043a\u0430\u043a\u043e\u043c \u044d\u0442\u0430\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u043c [latex]K[\/latex]. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0412 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0444\u0430\u0439\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f [latex]N, P, Q, K. 1 \\leq K \\leq N \\leq 1000, P \\times Q \\leq &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=620\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":81,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[79,80,81,82],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/620"}],"collection":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=620"}],"version-history":[{"count":19,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/620\/revisions"}],"predecessor-version":[{"id":640,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/620\/revisions\/640"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}