{"id":3278,"date":"2017-11-26T19:45:53","date_gmt":"2017-11-26T16:45:53","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=3278"},"modified":"2017-12-06T00:24:21","modified_gmt":"2017-12-05T21:24:21","slug":"%d0%bc%d0%be%d0%bd%d1%81%d1%82%d1%80","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=3278","title":{"rendered":"\u041c\u043e\u043d\u0441\u0442\u0440"},"content":{"rendered":"<p><a href=\"http:\/\/codeforces.com\/problemset\/problem\/787\/A\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0437\u0430\u0434\u0430\u0447\u0438<\/a><\/p>\n<h2>\u0417\u0430\u0434\u0430\u0447\u0430:<\/h2>\n<p>\u041c\u043e\u043d\u0441\u0442\u0440 \u0433\u043e\u043d\u0438\u0442\u0441\u044f \u0437\u0430 \u0420\u0438\u043a\u043e\u043c \u0438 \u041c\u043e\u0440\u0442\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043b\u0430\u043d\u0435\u0442\u0435. \u041e\u043d\u0438 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u043f\u0443\u0433\u0430\u043d\u044b, \u0447\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043a\u0440\u0438\u0447\u0430\u0442. \u0422\u043e\u0447\u043d\u0435\u0435, \u0420\u0438\u043a \u043a\u0440\u0438\u0447\u0438\u0442 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438 [latex]b,[\/latex] [latex]b + a,[\/latex] [latex]b + 2a,[\/latex] [latex]b + 3a,[\/latex]\u2026, \u0430 \u041c\u043e\u0440\u0442\u0438 \u043a\u0440\u0438\u0447\u0438\u0442 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438 [latex]d,[\/latex] [latex]d + c,[\/latex]\u00a0[latex]d + 2c,[\/latex] [latex]d + 3c,[\/latex]\u2026.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-17535 aligncenter\" src=\"https:\/\/i0.wp.com\/cpp.mazurok.com\/wp-content\/uploads\/2017\/04\/ba58e8e7c79422be337c551c72c11c1b60763948.png?resize=300%2C225\" alt=\"\" width=\"300\" height=\"225\" \/><\/p>\n<p>\u041c\u043e\u043d\u0441\u0442\u0440 \u043f\u043e\u0439\u043c\u0430\u0435\u0442 \u0438\u0445, \u0435\u0441\u043b\u0438 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u043d\u0438 \u0437\u0430\u043a\u0440\u0438\u0447\u0430\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. \u0422\u0430\u043a \u0447\u0442\u043e \u043e\u043d \u0445\u043e\u0447\u0435\u0442 \u0437\u043d\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u043f\u043e\u0439\u043c\u0430\u0435\u0442 \u0438\u0445 (\u043f\u0435\u0440\u0432\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u0437\u0430\u043a\u0440\u0438\u0447\u0430\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e) \u0438\u043b\u0438 \u043e\u043d\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0437\u0430\u043a\u0440\u0438\u0447\u0430\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.<\/p>\n<h2>\u0412\u0432\u043e\u0434:<\/h2>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 [latex]a[\/latex]\u00a0\u0438\u00a0[latex]b[\/latex] \u00a0[latex](1\\leq a,[\/latex] \u00a0[latex]b\\leq 100).[\/latex]\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 [latex]c[\/latex]\u00a0\u0438\u00a0[latex]d[\/latex] [latex](1\\leq c,[\/latex] \u00a0[latex]d\\leq 100).[\/latex]\n<h2>\u0412\u044b\u0432\u043e\u0434:<\/h2>\n<p>\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u043e\u0433\u0434\u0430 \u0420\u0438\u043a \u0438 \u041c\u043e\u0440\u0442\u0438 \u0437\u0430\u043a\u0440\u0438\u0447\u0430\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0438\u043b\u0438\u00a0<span class=\"tex-span\">\u2009-\u20091<\/span>, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0437\u0430\u043a\u0440\u0438\u0447\u0430\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b:<\/h2>\n<table>\n<tbody>\n<tr>\n<td width=\"400\">\n<div>\u0412\u0432\u043e\u0434<\/div>\n<\/td>\n<td width=\"400\">\u0412\u044b\u0432\u043e\u0434<\/td>\n<\/tr>\n<tr>\n<td>20 2<br \/>\n9 19<\/td>\n<td>82<\/td>\n<\/tr>\n<tr>\n<td>2 1<br \/>\n16 12<\/td>\n<td>-1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u041a\u043e\u0434:<\/h2>\n<pre class=\"lang:java decode:true \">import java.util.*;\r\n\r\npublic class RickAndMorty {\r\n\r\n    public static void main(String[] args) {\r\n        int n, m;\r\n        Vector s = new Vector();\r\n        Scanner in = new Scanner(System.in);\r\n        System.out.print(\"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 a: \");\r\n        int a = in.nextInt();\r\n        System.out.print(\"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 b: \");\r\n        int b = in.nextInt();\r\n        System.out.print(\"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 c: \");\r\n        int c = in.nextInt();\r\n        System.out.print(\"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 d: \");\r\n        int d = in.nextInt();\r\n       \r\n        for(int i=0;i&lt;=100;i++)\r\n        {\r\n            for(int j=0;j&lt;=100;j++)\r\n            {\r\n                n=b+i*a;\r\n                m=d+j*c;\r\n                if(m==n)\r\n                {\r\n                    s.add(n);\r\n                }\r\n            }\r\n        }\r\n        if(s.isEmpty())\r\n        {\r\n            System.out.print(-1);\r\n        } else\r\n            System.out.print(s.firstElement());\r\n    }\r\n}<\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/h2>\n<p>\u0412 \u044d\u0442\u0438\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0438\u044f\u043c\u0438, \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043f\u0440\u0438 [latex]a[\/latex]\u00a0\u0438\u00a0[latex]c.[\/latex]<em>\u00a0<\/em>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u043d\u0438\u0445 2 \u0446\u0438\u043a\u043b\u0430. \u0422\u0430\u043a \u043a\u0430\u043a \u0440\u0430\u0432\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e, \u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0439, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u0435\u043a\u0442\u043e\u0440 \u0438 ,\u043a\u043e\u0433\u0434\u0430 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0440\u0430\u0432\u043d\u044b, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442. \u0417\u0430\u0442\u0435\u043c, \u0443\u0436\u0435 \u0432\u043d\u0435 \u0446\u0438\u043a\u043b\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u043b\u0438 \u0432\u0435\u043a\u0442\u043e\u0440, \u0438 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u043c -1, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043a\u0435 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0440\u0430\u0432\u043d\u044b \u043d\u0438 \u0440\u0430\u0437\u0443. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u0435\u043a\u0442\u043e\u0440 \u043d\u0435\u043f\u0443\u0441\u0442\u043e\u0439, \u0432\u044b\u0445\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u0430. \u041e\u043d \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u043e\u043c\u044b\u043c \u043f\u0435\u0440\u0432\u044b\u043c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u043a\u0440\u0438\u043a\u043e\u043c.<\/p>\n<p>&nbsp;<\/p>\n<p>\u0412\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430\u00a0<a href=\"https:\/\/ideone.com\/4Vr4Hq\">Ideone.com<\/a><\/p>\n<p><a href=\"http:\/\/cpp.mazurok.com\/monster\/\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0437\u0430\u0434\u0430\u0447\u0438 \u0417\u0430\u0434\u0430\u0447\u0430: \u041c\u043e\u043d\u0441\u0442\u0440 \u0433\u043e\u043d\u0438\u0442\u0441\u044f \u0437\u0430 \u0420\u0438\u043a\u043e\u043c \u0438 \u041c\u043e\u0440\u0442\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043b\u0430\u043d\u0435\u0442\u0435. \u041e\u043d\u0438 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u043f\u0443\u0433\u0430\u043d\u044b, \u0447\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043a\u0440\u0438\u0447\u0430\u0442. \u0422\u043e\u0447\u043d\u0435\u0435, \u0420\u0438\u043a \u043a\u0440\u0438\u0447\u0438\u0442 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438 [latex]b,[\/latex] [latex]b + a,[\/latex] [latex]b + 2a,[\/latex] [latex]b + 3a,[\/latex]\u2026, \u0430 \u041c\u043e\u0440\u0442\u0438 \u043a\u0440\u0438\u0447\u0438\u0442 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438 [latex]d,[\/latex] [latex]d + c,[\/latex]\u00a0[latex]d + 2c,[\/latex] [latex]d + 3c,[\/latex]\u2026. \u041c\u043e\u043d\u0441\u0442\u0440 \u043f\u043e\u0439\u043c\u0430\u0435\u0442 \u0438\u0445, \u0435\u0441\u043b\u0438 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=3278\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":101,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[318,41,319,134,219,75],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/3278"}],"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\/101"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3278"}],"version-history":[{"count":4,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/3278\/revisions"}],"predecessor-version":[{"id":3290,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/3278\/revisions\/3290"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}