{"id":357993,"date":"2024-05-21T00:02:26","date_gmt":"2024-05-21T00:02:26","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=357993"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=357993","title":{"rendered":"<span>\u0418\u0437\u0443\u0447\u0430\u0435\u043c Q#. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0413\u0440\u043e\u0432\u0435\u0440\u0430. \u041d\u0435 \u0431\u0443\u0434\u0438\u0442\u0435 \u0441\u043f\u044f\u0449\u0435\u0433\u043e \u0426\u0435\u0437\u0430\u0440\u044f<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><del><em>\u041a\u0440\u0438\u043f\u0442\u043e\u0445\u043e\u043c\u044f\u0447\u043a\u0430\u043c \u043f\u043e\u0441\u0432\u044f\u0449\u0430\u0435\u0442\u0441\u044f &#8230;<\/em><\/del><\/p>\n<p>  <\/p>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0413\u0440\u043e\u0432\u0435\u0440\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u0439, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0435\u0439 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e\u0438\u0441\u043a, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 &#171;\u0447\u0451\u0440\u043d\u044b\u0439 \u044f\u0449\u0438\u043a&#187; <strong>f: {0,1}^n to {0,1}^n<\/strong>, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e <strong>EXISTS!w:f(w)=a<\/strong>, \u0433\u0434\u0435 <strong>a<\/strong> \u2014 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u0421\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u0434\u043b\u044f <strong>f<\/strong> \u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e <strong>a<\/strong> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0440\u0430\u043a\u0443\u043b <strong>Uf: { |w> to |1>, |x> to |0> if |x> != |w> }<\/strong><\/p>\n<p>  <\/p>\n<h2 id=\"algoritm-grovera-dostatochno-prost\">\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0413\u0440\u043e\u0432\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442<\/h2>\n<p>  <\/p>\n<ol>\n<li>\u0417\u0430\u0434\u0430\u0451\u043c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 (\u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043a\u0443\u0431\u0438\u0442\u043e\u0432) \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>H|0><\/strong><\/li>\n<li>\u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 (\u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043e\u0446\u0435\u043d\u043a\u0438) \u043f\u0430\u0440\u0443 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u043c<br \/> \n<ul>\n<li>\u041e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f <strong>Uw: { |w> to -|w>, |x> to |x> if |x> != |w> }<\/strong> \u0438\u043b\u0438 <strong>Uw = I-2|w>&lt;w|<\/strong><\/li>\n<li>\u041e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 <strong>s=H|0><\/strong> <strong>Us = 2|s>&lt;s|-I<\/strong><\/li>\n<\/ul>\n<\/li>\n<li>\u0417\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0434\u043e\u043b\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e \u043e\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435)<\/li>\n<\/ol>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/post_images\/803\/68c\/7c8\/80368c7c815389039fa125ad7b23942c.jpg\" alt=\"\u041d\u0435 \u0431\u0443\u0434\u0438\u0442\u0435 \u0441\u043f\u044f\u0449\u0435\u0433\u043e \u0426\u0435\u0437\u0430\u0440\u044f!\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/803\/68c\/7c8\/80368c7c815389039fa125ad7b23942c.jpg\" data-blurred=\"true\"\/><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430 \u0448\u0438\u0444\u0440\u0430 \u0426\u0435\u0437\u0430\u0440\u044f &#8230;<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0428\u0438\u0444\u0440 \u0426\u0435\u0437\u0430\u0440\u044f \u2014 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u043e\u043d\u043e\u0430\u043b\u0444\u0430\u0432\u0438\u0442\u043d\u044b\u0445 \u0448\u0438\u0444\u0440\u043e\u0432, \u0433\u0434\u0435 \u0430\u043b\u0444\u0430\u0432\u0438\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u0430\u043a \u043a\u043e\u043b\u044c\u0446\u043e \u0432\u044b\u0447\u0435\u0442\u043e\u0432 <strong>Z|m<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u0418, \u0435\u0441\u043b\u0438 \u043a\u043b\u044e\u0447 <strong>key<\/strong> \u2014 \u0447\u0438\u0441\u043b\u043e \u0438\u0437 <strong>0..(m-1)<\/strong>, \u0430 <strong>x(i)<\/strong> \u2014 \u0433\u0434\u0435 <strong>i=0..(l-1)<\/strong> \u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0438\u0437 <strong>0..(m-1)<\/strong>, \u0442\u043e<br \/>  <strong>y(i) = (x(i)+key) mod m<\/strong> \u2014 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u043c.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, <strong>x(i) = (y(i) \u2014 key) mod m = (y(i) + (m-key)) mod m<\/strong> \u2014 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043e\u0439 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<h2 id=\"postanovka-zadachi\">\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0438\u0437 <strong>Z|m<\/strong> \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e \u0438\u043b\u0438 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0441\u043e\u0432\u0441\u0435\u043c.<\/p>\n<p>  <\/p>\n<h3 id=\"chto-budet-oznachat-dannyy-fakt\">\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u043a\u0442?<\/h3>\n<p>  <\/p>\n<p>\u0422\u043e \u0447\u0442\u043e \u0438\u043c\u0435\u044f \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442 <strong>y(i)<\/strong> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430 <strong>key<\/strong><\/li>\n<li>\u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 <strong>x(i)<\/strong><\/li>\n<li>\u0443 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 <strong>x(i)<\/strong> \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e &#171;\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445&#187; \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0435\u0445 \u2014 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0441\u043e\u0432\u0441\u0435\u043c (\u0438\u043b\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u0434\u043a\u043e)<\/li>\n<li>\u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0442\u043e\u0442 \u2014 \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e &#171;\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445&#187; \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0440\u0430\u0432\u043d\u043e \u043d\u043e\u043b\u044c (\u0438\u043b\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e)<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442\u0443, \u0437\u043d\u0430\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430, \u043c\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0433\u0440\u0443\u0431\u043e\u0439 \u0441\u0438\u043b\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430 \u0448\u0438\u0444\u0440\u0430 \u0426\u0435\u0437\u0430\u0440\u044f.<\/p>\n<p>  <\/p>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0443\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0414\u0430\u043d\u043e <strong>Error|y:Z|m->N+0<\/strong><\/li>\n<li>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0442\u0430\u043a\u043e\u0439 <strong>key<\/strong>, \u0447\u0442\u043e <strong>Error(key)=0<\/strong> (\u0438\u043b\u0438 <strong>Error(key)&lt;const<\/strong>)<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0410 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0413\u0440\u043e\u0432\u0435\u0440\u0430<\/p>\n<p>  <\/p>\n<p>NB. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0431\u043b\u043e\u0447\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u0430 \u043a\u0430\u043a \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 <strong>ECB<\/strong>, \u0442\u0430\u043a \u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 <strong>CBC<\/strong><\/p>\n<p>  <\/p>\n<h2 id=\"pereydyom-k-realizacii-na-q\">\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 Q<\/h2>\n<p>  <\/p>\n<p>\u041f\u0443\u0441\u0442\u044c <strong>m=2^n<\/strong> \u0438 \u043f\u0440\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0440\u0430\u0437\u0440\u044f\u0434 \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430-\u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0432\u0435\u043d 0.<\/p>\n<p>  <\/p>\n<h3 id=\"realizuem-sleduyuschie-metody\">\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/h3>\n<p>  <\/p>\n<ol>\n<li>\u041c\u0435\u0442\u043e\u0434 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438 \u043d\u0430\u0434 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u043c \u0438\u0437 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u2014 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f <strong>Inc:|k> to |k+1><\/strong><br \/> \n<pre><code class=\"plaintext\">\/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \/\/\/ \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 (\u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043a\u0430\u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440) \/\/\/ \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432\u0438\u0434\u0430 |k> -> |k+1> operation Inc(target: Qubit[]) : Unit is Ctl {     let n = Length(target);     for idx in 1..n {         Controlled X(target[0..n-idx-1], target[n-idx]);     }  }<\/code><\/pre>\n<\/li>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438 \u043d\u0430\u0434 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u043c \u0438\u0437 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u2014 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 value, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f <strong>Add(value):|k> to |k+value><\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \/\/\/ \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 (\u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043a\u0430\u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440) \/\/\/ \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432\u0438\u0434\u0430 |k> -> |k+value> operation Add(target: Qubit[], value: Int) : Unit {     let n = Length(target);     let bools = IntAsBoolArray(value, n);     use (qubits) = (Qubit[2]) {         for idx in 0..n-1 {             let carry = qubits[idx%2];             let next = qubits[1-(idx%2)];             \/\/ \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0440\u0430\u0437\u0440\u044f\u0434\u0430             if(bools[idx]) {                 \/\/ next = carry*target[idx]^carry^target[idx] = carry|target[idx]                 Controlled X([carry, target[idx]], next);                 Controlled X([carry], next);                 Controlled X([target[idx]], next);             }             else {                 \/\/ next = carry*target[idx] = carry&amp;target[idx]                 Controlled X([carry, target[idx]], next);             }              \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u043a\u0443\u0448\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u0431\u0438\u0442\u0430             Controlled X([carry], target[idx]);             if(bools[idx]) {                 X(target[idx]);             }             Reset(carry);         }          ResetAll(qubits);     } }<\/code><\/pre>\n<p>  <\/li>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 (\u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0432\u0432\u0435\u0434\u0451\u043d\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430)<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \/\/\/ \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430 (\u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439) operation RandomPlain(n: Int, l: Int) : Int[] {     mutable plain = [0, size = l];     use qubits = Qubit[n-1] { \/\/ !!! \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043b\u0438 \u043d\u0430\u0431\u043e\u0440 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 - \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0430 \u0431\u0435\u0437 \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u044f\u0434\u0430         for idx in 0..l-1 {             ApplyToEach(H, qubits);             set plain w\/= idx &lt;- Measure(qubits);             ResetAll(qubits);         }     }     return plain; }  \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \/\/\/ \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 operation RandomKey(n: Int) : Int {     use qubits = Qubit[n] {         ApplyToEach(H, qubits);         let key = Measure(qubits);         ResetAll(qubits);         return key;     } }<\/code><\/pre>\n<p>  <\/li>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0448\u0438\u0444\u0440\u043e\u043c \u0426\u0435\u0437\u0430\u0440\u044f<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \/\/\/ \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0437 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u043a\u043b\u044e\u0447\u0435 (key) \/\/\/ \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0435\u043d\u043d\u043e, \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u0443 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u043e \u0441 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u0435\u043c (-key) operation Encrypt(n: Int, plain: Int[], key: Int) : Int[] {     let l = Length(plain);     let m = 2^n;     mutable cipher = [0, size = l];     for idx in 0..l-1 {         set cipher w\/= idx &lt;- (plain[idx]+key) % m;     }     return cipher; }  \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \/\/\/ \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 operation Copy(source: Qubit[], target: Qubit[]) : Unit {     let n = Length(source);     for i in 0..(n-1) {         Controlled X([source[i]], target[i]);     } }  \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \/\/\/ \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0448\u0438\u0444\u0440\u0430 \u0446\u0435\u0437\u0430\u0440\u044f (\u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430) \u043d\u0430 \u043a\u0443\u0431\u0438\u0442\u0430\u0445 \/\/\/ \u0442\u043e \u0435\u0441\u0442\u044c, \u0434\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043a\u043b\u044e\u0447\u0430 key \u0438\u043c\u0435\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432\u044b\u0445\u043e\u0434\u0430 \/\/\/ \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 - \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430 (-key) \/\/\/ \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430, \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u043e\u0441\u0438\u043c\u0432\u043e\u043b\u0430 operation EncryptChar(n: Int, ch: Int, cipher: Qubit[], key: Qubit[]) : Unit {     Copy(key, cipher);     Add(cipher, ch); } <\/code><\/pre>\n<p>  <\/li>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434 \u043f\u043e\u0434\u0441\u0447\u0451\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 &#171;\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445&#187; \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \/\/\/ \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \"\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445\" \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \/\/\/ \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u043a\u043b\u044e\u0447\u0435 operation CountErrorsOnDecrypt(n: Int, cipher: Int[], key: Qubit[], error: Qubit[]) : Unit {     \/\/ \u0414\u043b\u044f \u0448\u0438\u0444\u0440\u0430 \u0426\u0435\u0437\u0430\u0440\u044f plain = cipher - key = chiper + (-key)     \/\/ \u0430 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434 Add, \u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0437\u043d\u0430\u043a \u0447\u0438\u0441\u043b\u0430 key     \/\/ key = -key = ~key+1     ApplyToEach(X, key);     Inc(key);      use (plain) = (Qubit[n]) {         for ch in cipher {             EncryptChar(n, ch, plain, key);             \/\/ \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u043b\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0431\u0435\u0437 \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u044f\u0434\u0430             \/\/ \u0442\u043e \u043a\u0430\u0436\u0434\u043e\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0432 \u0441\u0442\u0430\u0440\u0448\u0435\u043c \u0440\u0430\u0437\u0440\u044f\u0434\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u043e\u0439             \/\/ \u043d\u0430\u0439\u0434\u0451\u043c \u0447\u0438\u0441\u043b\u043e \u0442\u0430\u043a\u0438\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 error             Controlled Inc([plain[n-1]], error);             ResetAll(plain);         }     }      ApplyToEach(X, key);     Inc(key); }<\/code><\/pre>\n<p>  <\/li>\n<li>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u0440\u0430\u043a\u043b\u0430 \u2014 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0434\u0430\u0451\u0442 <strong>|1><\/strong> \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u043e\u0431\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e &#171;\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445&#187; \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0440\u0430\u0432\u043d\u043e 0<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \/\/\/ \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0440\u0430\u043a\u043b\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u043e\u0432\u0435\u0440\u0430 \/\/\/ \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 - \u044d\u0442\u043e \u0442\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0448\u0438\u0431\u043e\u043a operation NoErrorOracle(n: Int, cipher: Int[], key: Qubit[], target: Qubit): Unit {     let l = Length(cipher);     let k = BitSizeI(l);      use (error) = (Qubit[k]) {         CountErrorsOnDecrypt(n, cipher, key, error);         \/\/ \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0434\u043b\u044f error == 0, \u0442\u043e \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u043b\u044e\u0447         \/\/ \u0442\u043e\u0433\u0434\u0430, \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043e\u0440\u0430\u043a\u0443\u043b\u0430 Uf(x,y)=(x,y^f(x)),         \/\/ \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043a\u0443\u0431\u0438\u0442, \u0435\u0441\u043b\u0438 error == 0         ApplyToEach(X, error);         Controlled X(error, target);         ResetAll(error);     } }<\/code><\/pre>\n<p>  <\/li>\n<li>\u041c\u0435\u0442\u043e\u0434\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0413\u0440\u043e\u0432\u0435\u0440\u0430 (\u0432\u0437\u044f\u0442\u043e \u0441 <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/azure\/quantum\/tutorial-qdk-grovers-search?tabs=tabid-visualstudio\" rel=\"nofollow noopener noreferrer\">https:\/\/learn.microsoft.com\/ru-ru\/azure\/quantum\/tutorial-qdk-grovers-search?tabs=tabid-visualstudio<\/a>)<br \/> \n<ul>\n<li>\u041e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<br \/> \n<pre><code class=\"plaintext\">\/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \/\/\/ \u0448\u0430\u0433 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u043e\u0432\u0435\u0440\u0430 \/\/\/ \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f     operation ReflectAboutSolution(oracle : (Qubit[], Qubit) => Unit, register : Qubit[]) : Unit { use (target)=(Qubit()){     within {         X(target);         H(target);     }     apply {         oracle(register, target);     } } }<\/code><\/pre>\n<\/li>\n<li>\u041e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 <strong>H|0><\/strong><br \/> \n<pre><code class=\"plaintext\">\/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \/\/\/ \u0448\u0430\u0433 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u043e\u0432\u0435\u0440\u0430 \/\/\/ \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 H|0> operation ReflectAboutUniform(inputQubits : Qubit[]) : Unit { within {     ApplyToEachA(H, inputQubits);     ApplyToEachA(X, inputQubits); } apply {     Controlled Z(Most(inputQubits), Tail(inputQubits)); } }<\/code><\/pre>\n<\/li>\n<li>\u0418, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0446\u0438\u043a\u043b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0413\u0440\u043e\u0432\u0435\u0440\u0430<br \/> \n<pre><code class=\"plaintext\">\/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \/\/\/ \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0433\u0440\u043e\u0432\u0435\u0440\u0430 operation RunGroversSearch(register : Qubit[], oracle : (Qubit[], Qubit) => Unit, iterations : Int) : Unit { ApplyToEach(H, register); for _ in 1 .. iterations {     ReflectAboutSolution(oracle, register);     ReflectAboutUniform(register); } }<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>  <\/p>\n<h2 id=\"podgotovim-test\">\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0442\u0435\u0441\u0442<\/h2>\n<p>  <\/p>\n<ol>\n<li>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0440\u0430\u043a\u043b\u0430 \u0441 \u043f\u043e\u043c\u043e\u0448\u044c\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u0443\u0431\u043e\u0439 \u0441\u0438\u043b\u044b<br \/> \n<pre><code class=\"plaintext\">        \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043e\u0440\u0430\u043a\u043b\u0430         \/\/ \u043f\u0440\u043e\u0433\u043e\u043d\u0438\u043c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u0431\u0440\u0443\u0442\u0442\u043e-\u0444\u043e\u0440\u0441         for i in 0..m-1 {             use (qubits, oracle) = (Qubit[n], Qubit()){                 Add(qubits, i);                 noErrorOracle(qubits, oracle);                 let hacked = Measure(qubits);                 Message($\"BruteForce: {key}=={hacked} ... oracle = {M(oracle)}\");                 if(M(oracle)==One){                     let plain = Encrypt(n, cipher, m-hacked);                     Message($\"BruteForce: Success!!! {key}=={hacked} ... plain = {plain}\");                 }                 ResetAll(qubits);                 Reset(oracle);             }         }<\/code><\/pre>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0413\u0440\u043e\u0432\u0435\u0440\u0430 \u0432 \u0434\u0432\u0443\u0445 \u0440\u0435\u0436\u0438\u043c\u0430\u0445:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0441 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430<br \/> \n<pre><code class=\"plaintext\">    \/\/ \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0433\u0440\u043e\u0432\u0435\u0440\u0430     \/\/ \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0448\u0430\u0433\u043e\u0432 \u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430     set isSuccess = false;     repeat {         use (qubits, oracle) = (Qubit[n], Qubit()){             let iterations = Round(PI()\/4.0*Sqrt(IntAsDouble(m)));             RunGroversSearch(qubits, noErrorOracle, iterations);             noErrorOracle(qubits, oracle);             let hacked = Measure(qubits);             Message($\"GroversSearch: iterations = {iterations} ... {key}=={hacked} ... oracle = {M(oracle)}\");             if(M(oracle)==One){                 set isSuccess = true;                 let plain = Encrypt(n, cipher, m-hacked);                 Message($\"GroversSearch: Success!!! {key}=={hacked} ... plain = {plain}\");             }             ResetAll(qubits);             Reset(oracle);         }     }     until(isSuccess);<\/code><\/pre>\n<\/li>\n<li>\n<p>\u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">    \/\/ \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0433\u0440\u043e\u0432\u0435\u0440\u0430     \/\/ \u0442\u043e\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0448\u0430\u0433\u043e\u0432 \u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c (\u0437\u043d\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0446\u0435\u043d\u043a\u0443)     \/\/ \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439     \/\/ \u041f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e\u0441\u043b\u0435 groverIterations \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438     \/\/ \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0443\u0441\u043f\u0435\u0445\u0430 \u043d\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 2*groverIterations.     \/\/ \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0441\u043d\u043e\u0432\u0430 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u0434\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 3*groverIterations \u0438 \u0442. \u0434.     \/\/ \u0412 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438\u043c\u0435\u0435\u0442 \u0432\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430,      \/\/ \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0432\u044b \u0440\u0435\u0448\u0438\u0442\u0435 \u0435\u0435. \u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0435\u0439 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f      \/\/ \"\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\" \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043f\u0443\u0442\u0435\u043c \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438 (\u0442. \u0435. 1,2,4,8,...).     \/\/ \u041e\u0434\u043d\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u0438\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0448\u0435\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435     \/\/ \u0441\u043e \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u043e\u043a\u043e\u043b\u043e SQRT(2^n\/S)       mutable currenIterations = 0;     set isSuccess = false;     repeat{         set currenIterations = currenIterations+1;         use (qubits, oracle) = (Qubit[n], Qubit()){             RunGroversSearch(qubits, noErrorOracle, currenIterations);             noErrorOracle(qubits, oracle);             let hacked = Measure(qubits);             Message($\"GroversSearch: iterations = {currenIterations} ... {key}=={hacked} ... oracle = {M(oracle)}\");             if(M(oracle)==One){                 set isSuccess = true;                 let plain = Encrypt(n, cipher, m-hacked);                 Message($\"GroversSearch: Success!!! {key}=={hacked} ... plain = {plain}\");             }             ResetAll(qubits);             Reset(oracle);         }     }     until (isSuccess);<\/code><\/pre>\n<p>  <\/li>\n<\/ul>\n<p>  <\/li>\n<\/ol>\n<p>  <\/p>\n<h3 id=\"polnyy-tekst-koda\">\u041f\u043e\u043b\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043a\u043e\u0434\u0430<\/h3>\n<p>  <\/p>\n<pre><code class=\"plaintext\">namespace qcaesarianae {      open Microsoft.Quantum.Canon;     open Microsoft.Quantum.Intrinsic;     open Microsoft.Quantum.Arrays;     open Microsoft.Quantum.Convert;     open Microsoft.Quantum.Math;     open Microsoft.Quantum.Logical;     open Microsoft.Quantum.Diagnostics;      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 (\u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043a\u0430\u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440)     \/\/\/ \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432\u0438\u0434\u0430 |k> -> |k+1>     operation Inc(target: Qubit[]) : Unit is Ctl {         let n = Length(target);         for idx in 1..n {             Controlled X(target[0..n-idx-1], target[n-idx]);         }      }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 (\u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043a\u0430\u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440)     \/\/\/ \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432\u0438\u0434\u0430 |k> -> |k+value>     operation Add(target: Qubit[], value: Int) : Unit {         let n = Length(target);         let bools = IntAsBoolArray(value, n);         use (qubits) = (Qubit[2]) {             for idx in 0..n-1 {                 let carry = qubits[idx%2];                 let next = qubits[1-(idx%2)];                 \/\/ \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0440\u0430\u0437\u0440\u044f\u0434\u0430                 if(bools[idx]) {                     \/\/ next = carry*target[idx]^carry^target[idx] = carry|target[idx]                     Controlled X([carry, target[idx]], next);                     Controlled X([carry], next);                     Controlled X([target[idx]], next);                 }                 else {                     \/\/ next = carry*target[idx] = carry&amp;target[idx]                     Controlled X([carry, target[idx]], next);                 }                  \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u043a\u0443\u0448\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u0431\u0438\u0442\u0430                 Controlled X([carry], target[idx]);                 if(bools[idx]) {                     X(target[idx]);                 }                 Reset(carry);             }              ResetAll(qubits);         }     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u043a\u043e\u043b\u043b\u0430\u043f\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435) \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0440\u0435\u0433\u0438\u0441\u0442\u0440)     \/\/\/ \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0447\u0438\u0441\u043b\u0430 (\u0440\u0430\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438)     operation Measure(qubits: Qubit[]) : Int {         let results = ForEach(M, qubits);         let bools = ResultArrayAsBoolArray(results);         let i = BoolArrayAsInt(bools);         return i;     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430 (\u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439)     operation RandomPlain(n: Int, l: Int) : Int[] {         mutable plain = [0, size = l];         use qubits = Qubit[n-1] { \/\/ !!! \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043b\u0438 \u043d\u0430\u0431\u043e\u0440 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 - \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0430 \u0431\u0435\u0437 \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u044f\u0434\u0430             for idx in 0..l-1 {                 ApplyToEach(H, qubits);                 set plain w\/= idx &lt;- Measure(qubits);                 ResetAll(qubits);             }         }         return plain;     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430     operation RandomKey(n: Int) : Int {         use qubits = Qubit[n] {             ApplyToEach(H, qubits);             let key = Measure(qubits);             ResetAll(qubits);             return key;         }     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0437 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u043a\u043b\u044e\u0447\u0435 (key)     \/\/\/ \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0435\u043d\u043d\u043e, \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u0443 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u043e \u0441 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u0435\u043c (-key)     operation Encrypt(n: Int, plain: Int[], key: Int) : Int[] {         let l = Length(plain);         let m = 2^n;         mutable cipher = [0, size = l];         for idx in 0..l-1 {             set cipher w\/= idx &lt;- (plain[idx]+key) % m;         }         return cipher;     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043a\u0443\u0431\u0438\u0442\u043e\u0432     operation Copy(source: Qubit[], target: Qubit[]) : Unit {         let n = Length(source);         for i in 0..(n-1) {             Controlled X([source[i]], target[i]);         }     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0448\u0438\u0444\u0440\u0430 \u0446\u0435\u0437\u0430\u0440\u044f (\u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430) \u043d\u0430 \u043a\u0443\u0431\u0438\u0442\u0430\u0445     \/\/\/ \u0442\u043e \u0435\u0441\u0442\u044c, \u0434\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043a\u043b\u044e\u0447\u0430 key \u0438\u043c\u0435\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432\u044b\u0445\u043e\u0434\u0430     \/\/\/ \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 - \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430 (-key)     \/\/\/ \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430, \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u043e\u0441\u0438\u043c\u0432\u043e\u043b\u0430     operation EncryptChar(n: Int, ch: Int, cipher: Qubit[], key: Qubit[]) : Unit {         Copy(key, cipher);         Add(cipher, ch);     }       \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \"\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445\" \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f     \/\/\/ \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u043a\u043b\u044e\u0447\u0435     operation CountErrorsOnDecrypt(n: Int, cipher: Int[], key: Qubit[], error: Qubit[]) : Unit {         \/\/ \u0414\u043b\u044f \u0448\u0438\u0444\u0440\u0430 \u0426\u0435\u0437\u0430\u0440\u044f plain = cipher - key = chiper + (-key)         \/\/ \u0430 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434 Add, \u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0437\u043d\u0430\u043a \u0447\u0438\u0441\u043b\u0430 key         \/\/ key = -key = ~key+1         ApplyToEach(X, key);         Inc(key);          use (plain) = (Qubit[n]) {             for ch in cipher {                 EncryptChar(n, ch, plain, key);                 \/\/ \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u043b\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0431\u0435\u0437 \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u044f\u0434\u0430                 \/\/ \u0442\u043e \u043a\u0430\u0436\u0434\u043e\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0432 \u0441\u0442\u0430\u0440\u0448\u0435\u043c \u0440\u0430\u0437\u0440\u044f\u0434\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u043e\u0439                 \/\/ \u043d\u0430\u0439\u0434\u0451\u043c \u0447\u0438\u0441\u043b\u043e \u0442\u0430\u043a\u0438\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 error                 Controlled Inc([plain[n-1]], error);                 ResetAll(plain);             }         }          ApplyToEach(X, key);         Inc(key);     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0440\u0430\u043a\u043b\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u043e\u0432\u0435\u0440\u0430     \/\/\/ \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 - \u044d\u0442\u043e \u0442\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0448\u0438\u0431\u043e\u043a     operation NoErrorOracle(n: Int, cipher: Int[], key: Qubit[], target: Qubit): Unit {         let l = Length(cipher);         let k = BitSizeI(l);          use (error) = (Qubit[k]) {             CountErrorsOnDecrypt(n, cipher, key, error);             \/\/ \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0434\u043b\u044f error == 0, \u0442\u043e \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u043b\u044e\u0447             \/\/ \u0442\u043e\u0433\u0434\u0430, \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043e\u0440\u0430\u043a\u0443\u043b\u0430 Uf(x,y)=(x,y^f(x)),             \/\/ \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043a\u0443\u0431\u0438\u0442, \u0435\u0441\u043b\u0438 error == 0             ApplyToEach(X, error);             Controlled X(error, target);             ResetAll(error);         }     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0448\u0430\u0433 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u043e\u0432\u0435\u0440\u0430     \/\/\/ \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f         operation ReflectAboutSolution(oracle : (Qubit[], Qubit) => Unit, register : Qubit[]) : Unit {         use (target)=(Qubit()){             within {                 X(target);                 H(target);             }             apply {                 oracle(register, target);             }         }     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0448\u0430\u0433 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u043e\u0432\u0435\u0440\u0430     \/\/\/ \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 H|0>     operation ReflectAboutUniform(inputQubits : Qubit[]) : Unit {         within {             ApplyToEachA(H, inputQubits);             ApplyToEachA(X, inputQubits);         }         apply {             Controlled Z(Most(inputQubits), Tail(inputQubits));         }     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0433\u0440\u043e\u0432\u0435\u0440\u0430     operation RunGroversSearch(register : Qubit[], oracle : (Qubit[], Qubit) => Unit, iterations : Int) : Unit {         ApplyToEach(H, register);         for _ in 1 .. iterations {             ReflectAboutSolution(oracle, register);             ReflectAboutUniform(register);         }     }      @EntryPoint()     operation Main(n: Int, l: Int) : Unit {         Message(\"Hello quantum world!\");          let tests = 1;         for _ in 1..tests {             let m = 2^n;             Message($\"n = {n} ... l = {l} ... m = {m}\");              let key = RandomKey(n);             let cipher = Encrypt(n, RandomPlain(n, l), key);             Message($\"key = {key} cipher = {cipher}\");              let noErrorOracle = NoErrorOracle(n, cipher, _, _);              let groverIterations = Round(PI()\/4.0*Sqrt(IntAsDouble(m)));             Message($\"GroversSearch: groverIterations = {groverIterations}?\");              mutable isSuccess = false;              \/\/ \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0433\u0440\u043e\u0432\u0435\u0440\u0430             \/\/ \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0448\u0430\u0433\u043e\u0432 \u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430             set isSuccess = false;             repeat {                 use (qubits, oracle) = (Qubit[n], Qubit()){                     let iterations = Round(PI()\/4.0*Sqrt(IntAsDouble(m)));                     RunGroversSearch(qubits, noErrorOracle, iterations);                     noErrorOracle(qubits, oracle);                     let hacked = Measure(qubits);                     Message($\"GroversSearch: iterations = {iterations} ... {key}=={hacked} ... oracle = {M(oracle)}\");                     if(M(oracle)==One){                         set isSuccess = true;                         let plain = Encrypt(n, cipher, m-hacked);                         Message($\"GroversSearch: Success!!! {key}=={hacked} ... plain = {plain}\");                     }                     ResetAll(qubits);                     Reset(oracle);                 }             }             until(isSuccess);              \/\/ \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0433\u0440\u043e\u0432\u0435\u0440\u0430             \/\/ \u0442\u043e\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0448\u0430\u0433\u043e\u0432 \u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c (\u0437\u043d\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0446\u0435\u043d\u043a\u0443)             \/\/ \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439             \/\/ \u041f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e\u0441\u043b\u0435 groverIterations \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438             \/\/ \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0443\u0441\u043f\u0435\u0445\u0430 \u043d\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 2*groverIterations.             \/\/ \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0441\u043d\u043e\u0432\u0430 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u0434\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 3*groverIterations \u0438 \u0442. \u0434.             \/\/ \u0412 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438\u043c\u0435\u0435\u0442 \u0432\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430,              \/\/ \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0432\u044b \u0440\u0435\u0448\u0438\u0442\u0435 \u0435\u0435. \u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0435\u0439 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f              \/\/ \"\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\" \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043f\u0443\u0442\u0435\u043c \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438 (\u0442. \u0435. 1,2,4,8,...).             \/\/ \u041e\u0434\u043d\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u0438\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0448\u0435\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435             \/\/ \u0441\u043e \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u043e\u043a\u043e\u043b\u043e SQRT(2^n\/S)               mutable currenIterations = 0;             set isSuccess = false;             repeat{                 set currenIterations = currenIterations+1;                 use (qubits, oracle) = (Qubit[n], Qubit()){                     RunGroversSearch(qubits, noErrorOracle, currenIterations);                     noErrorOracle(qubits, oracle);                     let hacked = Measure(qubits);                     Message($\"GroversSearch: iterations = {currenIterations} ... {key}=={hacked} ... oracle = {M(oracle)}\");                     if(M(oracle)==One){                         set isSuccess = true;                         let plain = Encrypt(n, cipher, m-hacked);                         Message($\"GroversSearch: Success!!! {key}=={hacked} ... plain = {plain}\");                     }                     ResetAll(qubits);                     Reset(oracle);                 }             }             until (isSuccess);              \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043e\u0440\u0430\u043a\u043b\u0430             \/\/ \u043f\u0440\u043e\u0433\u043e\u043d\u0438\u043c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u0431\u0440\u0443\u0442\u0442\u043e-\u0444\u043e\u0440\u0441             for i in 0..m-1 {                 use (qubits, oracle) = (Qubit[n], Qubit()){                     Add(qubits, i);                     noErrorOracle(qubits, oracle);                     let hacked = Measure(qubits);                     Message($\"BruteForce: {key}=={hacked} ... oracle = {M(oracle)}\");                     if(M(oracle)==One){                         let plain = Encrypt(n, cipher, m-hacked);                         Message($\"BruteForce: Success!!! {key}=={hacked} ... plain = {plain}\");                     }                     ResetAll(qubits);                     Reset(oracle);                 }             }         }     } }<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"i-sobstvenno-potestim-\">\u0418 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u0442\u0435\u0441\u0442\u0438\u043c &#8230;<\/h3>\n<p>  <\/p>\n<pre><code class=\"plaintext\">PS C:\\Projects\\qcaesarianae> dotnet run -n 3 -l 32 Hello quantum world! n = 3 ... l = 32 ... m = 8 key = 4 cipher = [6,4,6,6,6,7,6,5,4,4,4,7,4,7,6,4,7,7,6,7,5,6,4,6,6,7,7,5,4,7,6,4] GroversSearch: groverIterations = 2? GroversSearch: iterations = 2 ... 4==5 ... oracle = Zero GroversSearch: iterations = 2 ... 4==6 ... oracle = Zero GroversSearch: iterations = 2 ... 4==3 ... oracle = Zero GroversSearch: iterations = 2 ... 4==6 ... oracle = Zero GroversSearch: iterations = 2 ... 4==1 ... oracle = Zero GroversSearch: iterations = 2 ... 4==6 ... oracle = Zero GroversSearch: iterations = 2 ... 4==3 ... oracle = Zero GroversSearch: iterations = 2 ... 4==2 ... oracle = Zero GroversSearch: iterations = 2 ... 4==6 ... oracle = Zero GroversSearch: iterations = 2 ... 4==7 ... oracle = Zero GroversSearch: iterations = 2 ... 4==5 ... oracle = Zero GroversSearch: iterations = 2 ... 4==5 ... oracle = Zero GroversSearch: iterations = 2 ... 4==6 ... oracle = Zero GroversSearch: iterations = 2 ... 4==1 ... oracle = Zero GroversSearch: iterations = 2 ... 4==0 ... oracle = Zero GroversSearch: iterations = 2 ... 4==5 ... oracle = Zero GroversSearch: iterations = 2 ... 4==4 ... oracle = One GroversSearch: Success!!! 4==4 ... plain = [2,0,2,2,2,3,2,1,0,0,0,3,0,3,2,0,3,3,2,3,1,2,0,2,2,3,3,1,0,3,2,0] GroversSearch: iterations = 1 ... 4==1 ... oracle = Zero GroversSearch: iterations = 2 ... 4==4 ... oracle = One GroversSearch: Success!!! 4==4 ... plain = [2,0,2,2,2,3,2,1,0,0,0,3,0,3,2,0,3,3,2,3,1,2,0,2,2,3,3,1,0,3,2,0] BruteForce: 4==0 ... oracle = Zero BruteForce: 4==1 ... oracle = Zero BruteForce: 4==2 ... oracle = Zero BruteForce: 4==3 ... oracle = Zero BruteForce: 4==4 ... oracle = One BruteForce: Success!!! 4==4 ... plain = [2,0,2,2,2,3,2,1,0,0,0,3,0,3,2,0,3,3,2,3,1,2,0,2,2,3,3,1,0,3,2,0] BruteForce: 4==5 ... oracle = Zero BruteForce: 4==6 ... oracle = Zero BruteForce: 4==7 ... oracle = Zero<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"itog\">\u0418\u0442\u043e\u0433<\/h2>\n<p>  <\/p>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0413\u0440\u043e\u0432\u0435\u0440\u0430 \u0434\u0430\u0451\u0442 \u043e\u0446\u0435\u043d\u043a\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u043a\u0430\u043a PI\/4*SQRT(2^n\/S), \u0433\u0434\u0435 <strong>S<\/strong> \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>  <\/p>\n<p>NB. \u0410 \u0432\u044b \u0442\u043e\u0447\u043d\u043e \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u0432 \u0441 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439 \u0444\u043e\u043d \u041d\u0435\u0439\u043c\u0430\u043d\u043e\u0432\u0441\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u044e\u0442(-\u043b\u0438), \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0413\u0440\u043e\u0432\u0435\u0440\u0430 \u0441 \u043e\u0446\u0435\u043d\u043a\u043e\u0439 \u0447\u0438\u0441\u043b\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 <strong>O(log(2^n))<\/strong> \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e <strong>O(n)<\/strong> \u2014 \u0432\u0435\u0434\u044c \u0438 \u043f\u0440\u043e \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0447\u0438\u0441\u0435\u043b \u043c\u043d\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u2026 \u0445\u043e-\u0445\u043e-\u0445\u043e ?<\/p>\n<p>  <\/p>\n<h2 id=\"ssylki\">\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/dprotopopov\/qcaesarianae\" rel=\"nofollow noopener noreferrer\">https:\/\/github.com\/dprotopopov\/qcaesarianae<\/a><\/li>\n<li><a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A8%D0%B8%D1%84%D1%80_%D0%A6%D0%B5%D0%B7%D0%B0%D1%80%D1%8F\" rel=\"nofollow noopener noreferrer\">https:\/\/ru.wikipedia.org\/wiki\/\u0428\u0438\u0444\u0440_\u0426\u0435\u0437\u0430\u0440\u044f<\/a><\/li>\n<li><a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC_%D0%93%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%B0\" rel=\"nofollow noopener noreferrer\">https:\/\/ru.wikipedia.org\/wiki\/\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c_\u0413\u0440\u043e\u0432\u0435\u0440\u0430<\/a><\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/ru-ru\/azure\/quantum\/tutorial-qdk-grovers-search?tabs=tabid-visualstudio\" rel=\"nofollow noopener noreferrer\">https:\/\/learn.microsoft.com\/ru-ru\/azure\/quantum\/tutorial-qdk-grovers-search?tabs=tabid-visualstudio<\/a><\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/ru-ru\/azure\/quantum\/user-guide\/host-programs?tabs=tabid-copilot\" rel=\"nofollow noopener noreferrer\">https:\/\/learn.microsoft.com\/ru-ru\/azure\/quantum\/user-guide\/host-programs?tabs=tabid-copilot<\/a><\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/ru-ru\/training\/modules\/qsharp-create-first-quantum-development-kit\/2-install-quantum-development-kit-code\" rel=\"nofollow noopener noreferrer\">https:\/\/learn.microsoft.com\/ru-ru\/training\/modules\/qsharp-create-first-quantum-development-kit\/2-install-quantum-development-kit-code<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"ranee\">\u0420\u0430\u043d\u0435\u0435<\/h2>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/p\/766512\/\">\u0418\u0437\u0443\u0447\u0430\u0435\u043c Q#. \u0414\u0435\u043b\u0430\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0431\u0438\u043d\u043e\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/p\/759352\/\">\u041f\u0435\u0440\u0432\u044b\u0435 \u0448\u0430\u0433\u0438 \u0432 Q#. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0414\u043e\u0439\u0447\u0430<\/a><\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/768666\/\"> https:\/\/habr.com\/ru\/articles\/768666\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><del><em>\u041a\u0440\u0438\u043f\u0442\u043e\u0445\u043e\u043c\u044f\u0447\u043a\u0430\u043c \u043f\u043e\u0441\u0432\u044f\u0449\u0430\u0435\u0442\u0441\u044f &#8230;<\/em><\/del><\/p>\n<p>  <\/p>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0413\u0440\u043e\u0432\u0435\u0440\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u0439, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0435\u0439 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e\u0438\u0441\u043a, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 &#171;\u0447\u0451\u0440\u043d\u044b\u0439 \u044f\u0449\u0438\u043a&#187; <strong>f: {0,1}^n to {0,1}^n<\/strong>, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e <strong>EXISTS!w:f(w)=a<\/strong>, \u0433\u0434\u0435 <strong>a<\/strong> \u2014 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u0421\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u0434\u043b\u044f <strong>f<\/strong> \u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e <strong>a<\/strong> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0440\u0430\u043a\u0443\u043b <strong>Uf: { |w> to |1>, |x> to |0> if |x> != |w> }<\/strong><\/p>\n<p>  <\/p>\n<h2 id=\"algoritm-grovera-dostatochno-prost\">\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0413\u0440\u043e\u0432\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442<\/h2>\n<p>  <\/p>\n<ol>\n<li>\u0417\u0430\u0434\u0430\u0451\u043c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 (\u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043a\u0443\u0431\u0438\u0442\u043e\u0432) \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>H|0><\/strong><\/li>\n<li>\u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 (\u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043e\u0446\u0435\u043d\u043a\u0438) \u043f\u0430\u0440\u0443 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u043c<br \/> \n<ul>\n<li>\u041e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f <strong>Uw: { |w> to -|w>, |x> to |x> if |x> != |w> }<\/strong> \u0438\u043b\u0438 <strong>Uw = I-2|w>&lt;w|<\/strong><\/li>\n<li>\u041e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 <strong>s=H|0><\/strong> <strong>Us = 2|s>&lt;s|-I<\/strong><\/li>\n<\/ul>\n<\/li>\n<li>\u0417\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0434\u043e\u043b\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e \u043e\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435)<\/li>\n<\/ol>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/post_images\/803\/68c\/7c8\/80368c7c815389039fa125ad7b23942c.jpg\" alt=\"\u041d\u0435 \u0431\u0443\u0434\u0438\u0442\u0435 \u0441\u043f\u044f\u0449\u0435\u0433\u043e \u0426\u0435\u0437\u0430\u0440\u044f!\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/803\/68c\/7c8\/80368c7c815389039fa125ad7b23942c.jpg\" data-blurred=\"true\"\/><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430 \u0448\u0438\u0444\u0440\u0430 \u0426\u0435\u0437\u0430\u0440\u044f &#8230;<\/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-357993","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/357993","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=357993"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/357993\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=357993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=357993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=357993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}