{"id":4787,"date":"2018-12-28T12:25:08","date_gmt":"2018-12-28T09:25:08","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=4787"},"modified":"2019-01-03T19:48:19","modified_gmt":"2019-01-03T16:48:19","slug":"e-olymp-1154-%d0%ba%d1%80%d1%83%d0%b6%d0%be%d0%ba-%d1%85%d0%be%d1%80%d0%be%d0%b2%d0%be%d0%b3%d0%be-%d0%bf%d0%b5%d0%bd%d0%b8%d1%8f","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=4787","title":{"rendered":"e-olymp 1154. \u041a\u0440\u0443\u0436\u043e\u043a \u0445\u043e\u0440\u043e\u0432\u043e\u0433\u043e \u043f\u0435\u043d\u0438\u044f"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430<\/h1>\n<p>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0447\u0435\u0431\u043d\u043e\u043c \u0437\u0430\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u043a\u0440\u0443\u0436\u043e\u043a \u0445\u043e\u0440\u043e\u0432\u043e\u0433\u043e \u043f\u0435\u043d\u0438\u044f. \u041d\u0430\u0447\u0430\u043b\u043e \u043a\u0440\u0443\u0436\u043a\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e: \u043f\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0443 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u043a\u0440\u0443\u0436\u043a\u0430 \u0432\u0441\u0435 [latex]N[\/latex] \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0432 \u043a\u0440\u0443\u0433 \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 [latex]M[\/latex]-\u0439 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0435\u0432\u043a\u0438 \u043f\u043e\u0451\u0442 \u0433\u0430\u043c\u043c\u0443.<\/p>\n<p>\u0420\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u043a\u0440\u0443\u0436\u043a\u0430 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u044f\u0442\u044c \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0435 \u0441\u0432\u044f\u0437\u043a\u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0434\u0430\u0451\u0442\u0441\u044f \u0432\u0441\u0435\u043c \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c \u043a\u0440\u0443\u0436\u043a\u0430. \u041f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c [latex]N[\/latex] \u0438 [latex]M[\/latex] \u043f\u043e\u043c\u043e\u0433\u0438\u0442\u0435 \u0435\u043c\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0438\u043b\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0430\u0437 \u0432 \u0440\u0430\u0437\u043c\u0438\u043d\u043a\u0435 \u043f\u0440\u0438\u043c\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432\u0441\u0435 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0438 \u0445\u043e\u0440\u0430.<\/p>\n<h2>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432. \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 [latex]N[\/latex] \u0438 [latex]M[\/latex]. ([latex]1 \u2264 N, M \u2264 103[\/latex]).<\/p>\n<h2>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u00abYES\u00bb, \u0435\u0441\u043b\u0438 \u0432 \u0440\u0430\u0437\u043c\u0438\u043d\u043a\u0435 \u043f\u0440\u0438\u043c\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432\u0441\u0435 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0438 \u0445\u043e\u0440\u0430, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u00abNO\u00bb.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<table style=\"height: 198px\" width=\"277\">\n<tbody>\n<tr>\n<th>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/th>\n<th>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/th>\n<\/tr>\n<tr>\n<td>1000 1000<br \/>\n1 1<\/td>\n<td>NO<br \/>\nYES<\/td>\n<\/tr>\n<tr>\n<td>2 5<br \/>\n3 7<br \/>\n14 15<br \/>\n49 37<\/td>\n<td>YES<br \/>\nYES<br \/>\nYES<br \/>\nYES<\/td>\n<\/tr>\n<tr>\n<td>14 16<br \/>\n891 6<br \/>\n441 9<br \/>\n777 111<\/td>\n<td>NO<br \/>\nNO<br \/>\nNO<br \/>\nNO<\/td>\n<\/tr>\n<tr>\n<td>4 1<br \/>\n6 3<\/td>\n<td>YES<br \/>\nNO<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h2>\n<pre class=\"lang:java decode:true \">import java.util.Scanner;\r\n \r\npublic class Main {\r\n\t   public static int gcd(int p, int q) {\r\n       \tif (q == 0) return p;\r\n       \telse return gcd(q, p % q);\r\n   \t}\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner sc = new Scanner(System.in);\r\n\t\tString a;\r\n\t\twhile(sc.hasNextInt()){\r\n    \t\tint p = sc.nextInt();\r\n    \t\tint q = sc.nextInt();\r\n    \t\ta = gcd(p, q)==1? \"YES\":\"NO\";\r\n    \t\tSystem.out.print(a + \"\\n\");\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c [latex]N[\/latex] \u043f\u0435\u0432\u0446\u043e\u0432. \u041f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u0443\u0435\u043c \u0438\u0445 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443 \u043e\u0442 [latex]0[\/latex] \u0434\u043e [latex]N &#8212; 1[\/latex]. \u0420\u0430\u0441\u043f\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 [latex]M[\/latex]-\u0439. \u0418 \u043f\u0443\u0441\u0442\u044c \u041d\u041e\u0414 ([latex]M, N) = k \\geq 2[\/latex]. \u0422\u043e\u0433\u0434\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, [latex]k &#8212; 1[\/latex]-\u044b\u0439 \u043f\u0435\u0432\u0435\u0446 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0440\u0430\u0441\u043f\u043e\u0435\u0442\u0441\u044f.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 <a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/1154\"> E-Olymp<\/a><\/p>\n<p>\u043a\u043e\u0434 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 <a href=\"https:\/\/ideone.com\/jD1n7E\">Ideone<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0447\u0435\u0431\u043d\u043e\u043c \u0437\u0430\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u043a\u0440\u0443\u0436\u043e\u043a \u0445\u043e\u0440\u043e\u0432\u043e\u0433\u043e \u043f\u0435\u043d\u0438\u044f. \u041d\u0430\u0447\u0430\u043b\u043e \u043a\u0440\u0443\u0436\u043a\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e: \u043f\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0443 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u043a\u0440\u0443\u0436\u043a\u0430 \u0432\u0441\u0435 [latex]N[\/latex] \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0432 \u043a\u0440\u0443\u0433 \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 [latex]M[\/latex]-\u0439 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0435\u0432\u043a\u0438 \u043f\u043e\u0451\u0442 \u0433\u0430\u043c\u043c\u0443. \u0420\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u043a\u0440\u0443\u0436\u043a\u0430 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u044f\u0442\u044c \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0435 \u0441\u0432\u044f\u0437\u043a\u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0434\u0430\u0451\u0442\u0441\u044f \u0432\u0441\u0435\u043c \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c \u043a\u0440\u0443\u0436\u043a\u0430. \u041f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c [latex]N[\/latex] \u0438 [latex]M[\/latex] \u043f\u043e\u043c\u043e\u0433\u0438\u0442\u0435 \u0435\u043c\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0438\u043b\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=4787\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":126,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[299,363,676],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4787"}],"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\/126"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4787"}],"version-history":[{"count":2,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4787\/revisions"}],"predecessor-version":[{"id":4790,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4787\/revisions\/4790"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4787"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}