{"id":205106,"date":"2013-12-07T12:28:02","date_gmt":"2013-12-07T08:28:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=205106"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=205106","title":{"rendered":"<span class=\"post_title\">\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u041d\u041e\u0414 \u2014 \u043e\u0448\u0438\u0431\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u044e\u0442<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u041d\u041e\u0414, \u0432\u0441\u0435 \u0437\u043d\u0430\u044e\u0442 \u0435\u0449\u0435 \u0441\u043e \u0448\u043a\u043e\u043b\u044b. \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u043e\u0434\u0437\u0430\u0431\u044b\u043b, \u043d\u0430\u043f\u043e\u043c\u043d\u044e: \u041d\u041e\u0414 \u2014 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c, \u0434\u0435\u043b\u044f\u0449\u0438\u0439 \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 \u0431\u0435\u0437 \u043e\u0441\u0442\u0430\u0442\u043a\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u041d\u041e\u0414 \u0447\u0438\u0441\u0435\u043b 100 \u0438 45 \u0440\u0430\u0432\u0435\u043d 5, \u0430 \u041d\u041e\u0414 \u0447\u0438\u0441\u0435\u043b 17 \u0438 7 \u0440\u0430\u0432\u0435\u043d 1. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043f\u043e\u0438\u0441\u043a\u0430 \u044d\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430. \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e <b>\u043f\u0440\u043e\u0441\u0442\u044b\u0435<\/b> \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u0447\u0430\u0441\u0442\u043e <b>\u0441\u043e\u0432\u0435\u0440\u0448\u0430\u044e\u0442<\/b> \u043e\u0434\u043d\u0443 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e, \u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443.<a name=\"habracut\"><\/a><\/p>\n<h5>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u041d\u041e\u0414<\/h5>\n<p>  \u042f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e 5 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u041d\u041e\u0414:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">1. \u0420\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u0438 \u043e\u0441\u0442\u0430\u0442\u043a\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">public static int gcd_1(int a, int b) { \tif (b == 0) \t\treturn a; \treturn gcd_1(b, a % b); } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">2. \u0422\u0435 \u0436\u0435 \u043e\u0441\u0442\u0430\u0442\u043a\u0438, \u043d\u043e \u0431\u0435\u0437 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">public static int gcd_2(int a, int b) { \tint t; \twhile (b != 0) { \t\tt = b; \t\tb = a % b; \t\ta = t; \t} \treturn a; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">3. \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0415\u0432\u043a\u043b\u0438\u0434\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">public static int gcd_3(int a, int b) { \twhile (a != b) { \t\tif (a &gt; b) { \t\t\ta = a - b; \t\t} else { \t\t\tb = b - a; \t\t} \t} \treturn a; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">4. \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u041d\u041e\u0414<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">public static int gcd_4(int a, int b) { \tif (a == b) \t\treturn a; \tif (a == 0) \t\treturn b; \tif (b == 0) \t\t\treturn a; \tif ((~a & 1) != 0) { \t\tif ((b & 1) != 0) \t\t\treturn gcd_4(a &gt;&gt; 1, b); \t\telse \t\t\treturn gcd_4(a &gt;&gt; 1, b &gt;&gt; 1) &lt;&lt; 1; \t} \tif ((~b & 1) != 0) \t\treturn gcd_4(a, b &gt;&gt; 1); \tif (a &gt; b) \t\treturn gcd_4((a - b) &gt;&gt; 1, b); \treturn gcd_4((b - a) &gt;&gt; 1, a); } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">5. \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">public static int gcd_5(int a, int b) { \tint shift; \tif (a == 0) \t\treturn b; \tif (b == 0) \t\treturn a; \tfor (shift = 0; ((a | b) & 1) == 0; ++shift) { \t\ta &gt;&gt;= 1; \t\tb &gt;&gt;= 1; \t} \twhile ((a & 1) == 0) \t\ta &gt;&gt;= 1; \t\tdo { \t\twhile ((b & 1) == 0) \t\t\tb &gt;&gt;= 1; \t\tif (a &gt; b) { \t\t\tint t = b; \t\t\tb = a; \t\t\ta = t; \t\t} \t\tb = b - a; \t} while (b != 0); \treturn a &lt;&lt; shift; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0438\u0448\u0443\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2014 \u043e\u043d \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f, \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<h5>\u041f\u0440\u0435\u0442\u0435\u0441\u0442\u044b<\/h5>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0430 \u0442\u0430\u043a\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445:  <\/p>\n<pre><code class=\"java\">gcd(1, 10) = 1 gcd(5, 10) = 5 gcd(24, 24) = 24 gcd(0, 0) = 0 gcd(5,10) = 5 <\/code><\/pre>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u043d\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445, \u0433\u0434\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0446\u0435\u043b\u044b\u0435 \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430. \u041d\u043e \u0447\u0442\u043e, \u0435\u0441\u043b\u0438\u2026<\/p>\n<h5>\u041f\u0435\u0440\u0432\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0441 \u043f\u043e\u0434\u0432\u043e\u0445\u043e\u043c<\/h5>\n<p>  \u2026 \u0435\u0441\u043b\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0437 \u0447\u0438\u0441\u0435\u043b \u043d\u0443\u043b\u0435\u043c? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"java\">gcd(5, 0) = 5 gcd(0, 15) = 15 <\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0415\u0432\u043a\u043b\u0438\u0434\u0430 (\u21163) \u0443\u0436\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b.<\/p>\n<h5>\u041a\u043e\u043f\u0430\u0435\u043c \u0433\u043b\u0443\u0431\u0436\u0435<\/h5>\n<p>  \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e, \u041d\u041e\u0414 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0434\u0432\u0443\u0445 <b>\u0446\u0435\u043b\u044b\u0445<\/b> \u0447\u0438\u0441\u0435\u043b. \u0422\u0430\u043a \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u0433\u0434\u0435 \u043e\u0434\u043d\u043e \u0438\u0437 \u0447\u0438\u0441\u0435\u043b \u2014 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435:  <\/p>\n<pre><code class=\"java\">gcd(-5,10) = ? <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0435\u0449\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435. \u041f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0434\u0430\u044e\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 <b>-5<\/b>. \u0422\u0440\u0435\u0442\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b. \u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u044f\u0442\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u0427\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u0439 \u043f\u0430\u0434\u0430\u0435\u0442 \u043f\u043e StackOverFlow \u2014 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0442\u043e\u0436\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b. <br \/>  \u041d\u043e \u0432\u0435\u0434\u044c \u043e\u0442\u0432\u0435\u0442 <b>-5<\/b> \u2014 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439. \u041f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u041d\u041e\u0414 \u2014 <b>\u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439<\/b> \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c. \u0410 \u0442\u0430\u043a\u043e\u0432\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e <b>5<\/b>. \u0412\u0435\u0434\u044c \u0438 \u043f\u0435\u0440\u0432\u043e\u0435, \u0438 \u0432\u0442\u043e\u0440\u043e\u0435 \u0447\u0438\u0441\u043b\u043e <u>\u0434\u0435\u043b\u044f\u0442\u0441\u044f \u0431\u0435\u0437 \u043e\u0441\u0442\u0430\u0442\u043a\u0430<\/u> \u043d\u0430 5. \u0417\u043d\u0430\u0447\u0438\u0442 \u0438 \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435 \u0434\u0430\u044e\u0442 \u0432\u0435\u0440\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442. <\/p>\n<h5>\u041f\u043e\u0447\u0435\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u2116\u21163-5 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b?<\/h5>\n<p>  \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0415\u0432\u043a\u043b\u0438\u0434\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0446\u0438\u043a\u043b \u0438\u0437-\u0437\u0430 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0435\u0441\u043b\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u044d\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c <b>a<\/b> (\u0438\u043b\u0438 <b>b<\/b>) \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c.  <\/p>\n<pre><code class=\"java\">if (a &gt; b) { \ta = a - b; } else { \tb = b - a; } <\/code><\/pre>\n<p>  \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u043c \u0438 \u043f\u044f\u0442\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435:  <\/p>\n<pre><code class=\"java\">if (a &gt; b) \treturn gcd_4((a - b) &gt;&gt; 1, b); return gcd_4((b - a) &gt;&gt; 1, a); <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"java\">if (a &gt; b) { \tint t = b; \tb = a; \ta = t; } b = b - a; <\/code><\/pre>\n<p>  \u0412 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 <b>a<\/b> \u0438\u043b\u0438 <b>b<\/b> \u0440\u0430\u0432\u043d\u044b <b>0<\/b>, \u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u043d\u0443\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<h5>\u0422\u0430\u043a \u0447\u0442\u043e \u0436\u0435 \u043d\u0435 \u0442\u0430\u043a?<\/h5>\n<p>  \u0412\u0441\u0435 \u044d\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0430 \u0447\u0438\u0441\u043b\u0430 <b>a<\/b> \u0438 <b>b<\/b> \u2014 \u0446\u0435\u043b\u044b\u0435 \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430. \u041d\u043e \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u0435\u0449\u0435 \u0440\u0430\u0437 \u2014 \u041d\u041e\u0414 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0434\u0432\u0443\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.<\/p>\n<h5>\u0427\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c?<\/h5>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u0435\u043b, \u0442\u043e\u0433\u0434\u0430 \u043e\u0442\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0435\u043d:  <\/p>\n<pre><code class=\"java\">int ans = gcd(Math.abs(a), Math.abs(b)); <\/code><\/pre>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430:  <\/p>\n<pre><code class=\"java\">public static int gcd(int a, int b) { \tif (b == 0) \t\treturn Math.abs(a); \treturn gcd(b, a % b); } <\/code><\/pre>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435: \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0448\u043d\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u0447\u0435\u043c \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435.<\/p>\n<h5>\u0418\u0442\u043e\u0433\u0438<\/h5>\n<p>  \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043f\u044f\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043e\u0431\u0449\u0435\u0433\u043e \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445 \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0442\u0432\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u00ab\u043f\u0430\u0434\u0430\u0435\u0442\u00bb, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. <br \/>  \u0422\u0430\u043a\u0438\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u044e\u0442 \u00ab\u0441\u043a\u043e\u043b\u044c\u0437\u043a\u0438\u0435\u00bb \u043c\u0435\u0441\u0442\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0438. \u0427\u0430\u0441\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u0447\u0430\u0441\u0442\u044c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u043c\u0435\u0447\u0435\u043d\u043d\u043e\u0439. <br \/>  \u0412 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0441 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435\u043c \u041d\u041e\u0414 <u>\u043f\u043e\u0447\u0442\u0438<\/u> \u0432\u0441\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439. \u0412 \u0421\u0435\u0442\u0438 \u044f \u043d\u0430\u0448\u0435\u043b \u043b\u0438\u0448\u044c \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u043e\u0441\u0442\u0430. <\/p>\n<h5>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0430, \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/h5>\n<p>  <\/p>\n<ul>\n<li> <a href=\"https:\/\/en.wikipedia.org\/wiki\/Binary_GCD_algorithm\">Binary GCD algorithm \u2014 Wikipedia<\/a><\/li>\n<li> <a href=\"https:\/\/en.wikipedia.org\/wiki\/Euclidean_algorithm\">Euclidean algorithm \u2014 Wikipedia<\/a><\/li>\n<li> <a href=\"http:\/\/e-maxx.ru\/algo\/euclid_algorithm\">\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0415\u0432\u043a\u043b\u0438\u0434\u0430 \u2014 e-maxx<\/a><\/li>\n<li> <a href=\"http:\/\/xlinux.nist.gov\/dads\/\/HTML\/binaryGCD.html\">Binary GCD \u2014 Dictionary of Algorithms and Data Structures<\/a><\/li>\n<li> \u041a\u043e\u0440\u043c\u0435\u043d \u2014 \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u2014 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437<\/li>\n<\/ul>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/205106\/\"> http:\/\/habrahabr.ru\/post\/205106\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u041d\u041e\u0414, \u0432\u0441\u0435 \u0437\u043d\u0430\u044e\u0442 \u0435\u0449\u0435 \u0441\u043e \u0448\u043a\u043e\u043b\u044b. \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u043e\u0434\u0437\u0430\u0431\u044b\u043b, \u043d\u0430\u043f\u043e\u043c\u043d\u044e: \u041d\u041e\u0414 \u2014 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u0449\u0438\u0439 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c, \u0434\u0435\u043b\u044f\u0449\u0438\u0439 \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 \u0431\u0435\u0437 \u043e\u0441\u0442\u0430\u0442\u043a\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u041d\u041e\u0414 \u0447\u0438\u0441\u0435\u043b 100 \u0438 45 \u0440\u0430\u0432\u0435\u043d 5, \u0430 \u041d\u041e\u0414 \u0447\u0438\u0441\u0435\u043b 17 \u0438 7 \u0440\u0430\u0432\u0435\u043d 1. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043f\u043e\u0438\u0441\u043a\u0430 \u044d\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430. \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e <b>\u043f\u0440\u043e\u0441\u0442\u044b\u0435<\/b> \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u0447\u0430\u0441\u0442\u043e <b>\u0441\u043e\u0432\u0435\u0440\u0448\u0430\u044e\u0442<\/b> \u043e\u0434\u043d\u0443 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e, \u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-205106","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/205106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=205106"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/205106\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=205106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=205106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=205106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}