{"id":358158,"date":"2024-05-21T00:05:46","date_gmt":"2024-05-21T00:05:46","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=358158"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=358158","title":{"rendered":"<span>\u0418\u0437\u0443\u0447\u0430\u0435\u043c Q#. \u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0447\u0438\u0441\u0435\u043b<\/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-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b6e\/5cd\/119\/b6e5cd11923181777da53a400f70653a.png\" data-src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b6e\/5cd\/119\/b6e5cd11923181777da53a400f70653a.png\"\/><\/figure>\n<p>\u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u043e\u0432\u044b\u0439 \u043c\u0438\u0440 \u043d\u043e\u0432\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439!<\/p>\n<p>\u0412 \u0431\u044b\u0442\u0443, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b, \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u044c &#8212; \u043f\u043e\u0445\u043e\u0436\u0438 \u043b\u0438 \u043e\u043d\u0438 \u0438\u043b\u0438 \u043d\u0435\u0442, \u0438 \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0438 \u043f\u043e\u0445\u043e\u0436\u0438.<\/p>\n<p>\u0422\u0430\u043a \u0438 \u0432 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435 &#8212; \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0447\u0438\u0441\u0435\u043b, \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u044c &#8212; \u043f\u043e\u0445\u043e\u0436\u0438 \u043b\u0438 \u043e\u043d\u0438 \u0438\u043b\u0438 \u043d\u0435\u0442, \u0438 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0438 \u043f\u043e\u0445\u043e\u0436\u0438.<\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 &#171;\u043f\u043e\u0445\u043e\u0436\u0435\u0441\u0442\u0438&#187; \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u044d\u0442\u0438\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043a\u0443-\u0442\u0435\u0441\u0442 \u043d\u0430 Q-sharp \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u044d\u0442\u0438\u0445 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043f\u043e<\/p>\n<ul>\n<li>\n<p>\u0442\u0435\u043e\u0440\u0438\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438<\/p>\n<\/li>\n<li>\n<p>\u0430\u043b\u0433\u0435\u0431\u0440\u0435<\/p>\n<\/li>\n<li>\n<p>\u0431\u0443\u043b\u0435\u0432\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c<\/p>\n<\/li>\n<li>\n<p>\u0441\u0432\u0451\u0440\u0442\u043a\u0435, \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438, \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044e<\/p>\n<\/li>\n<li>\n<p>\u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c (\u043a\u0443\u0431\u0438\u0442\u044b \u0438 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438)<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043d\u0430 Q-sharp<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>\u041f\u0443\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c <strong>x(i)<\/strong> \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0438\u0437 <strong>0..m-1<\/strong>, \u0433\u0434\u0435 <strong>i=0..l-1<\/strong><\/p>\n<p>\u0421\u043f\u0440\u043e\u0441\u0438\u043c \u0441\u0435\u0431\u044f &#8212; \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u043c\u0430\u0441\u0441\u0438\u0432\u0430) \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 <strong>SUM SQRT(P(v))|v><\/strong>, \u0433\u0434\u0435 <strong>P(v)<\/strong> &#8212; \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 <strong>v<\/strong> \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <strong>x(i)<\/strong>?<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 &#8212; \u0430 \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0438 \u043d\u0435\u0442 (\u043d\u043e \u0441 \u043e\u0433\u043e\u0432\u043e\u0440\u043a\u0430\u043c\u0438)!<\/p>\n<p>\u0427\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c <strong>x(i)<\/strong>, \u0433\u0434\u0435 <strong>i=0..l-1<\/strong> ?<\/p>\n<p>\u042d\u0442\u043e \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (\u0444\u0443\u043d\u043a\u0446\u0438\u044f) <strong>x: 0..l-1 to 0..m-1<\/strong><\/p>\n<p>\u041f\u0443\u0441\u0442\u044c<\/p>\n<p><strong>kl<\/strong> &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b <strong>0..l-1<\/strong><br \/> <strong>km<\/strong> &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b <strong>0..m-1<\/strong><\/p>\n<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <strong>x: 0..l-1 to 0..m-1<\/strong> \u0432 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 <strong>Ux(i,z)=(i,z xor x(i))<\/strong><br \/> \u0433\u0434\u0435 <strong>i<\/strong> &#8212; \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0438\u0437 <strong>kl<\/strong> \u043a\u0443\u0431\u0438\u0442\u043e\u0432, \u0430 <strong>z<\/strong> &#8212; \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0438\u0437 <strong>km<\/strong> \u043a\u0443\u0431\u0438\u0442\u043e\u0432<\/p>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e <strong>Ux(H|0>,|0>)<\/strong>, \u0442\u043e (\u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <strong>i<\/strong> \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 <strong>0..2^kl-1<\/strong>) \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <strong>z<\/strong> \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041d\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>x<\/strong> \u043d\u0430 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 <strong>l..2^kl-1<\/strong>.<\/p>\n<p>\u0415\u0441\u0442\u044c \u043b\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f? \u041a\u043e\u043d\u0435\u0447\u043d\u043e!<\/p>\n<p>\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 &#8212; \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0443\u0447\u0430\u0441\u0442\u043a\u0435 <strong>l..2^kl-1<\/strong> \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0440\u0430\u0432\u043d\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0438\u0437 <strong>0..m-1<\/strong><\/p>\n<p>\u0418 \u0432\u0443\u0430\u043b\u044f &#8230;<\/p>\n<p>\u0418\u043c\u0435\u0435\u043c <strong>x:0..2^kl-1 to 0..m-1<\/strong> \u0438 <strong>Ux(i,z)=(i,z xor x(i))<\/strong><\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u0434\u0430\u0451\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 <strong>(i,z)=(H|0>,|0>)<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e <strong>Ux<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0418 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <strong>z<\/strong> \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043d\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u0440\u0435\u0434\u043d\u0451\u043d\u043d\u044b\u0435, \u0437\u0430 \u0441\u0447\u0451\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0445\u0432\u043e\u0441\u0442\u0430 \u0438\u0437 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0440\u0430\u0432\u043d\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b)<\/p>\n<\/li>\n<\/ol>\n<h3>\u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 Ux ?<\/h3>\n<p>\u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0433\u0435\u0439\u0442\u043e\u0432 &#8212; <strong>X<\/strong> \u0438 <strong>Controlled X<\/strong><\/p>\n<p>\u041f\u0443\u0441\u0442\u044c <strong>x|j:0..2^kl-1 to 0..1<\/strong> &#8212; \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0432\u0437\u044f\u0442\u0438\u0435\u043c <strong>j<\/strong>-\u0433\u043e \u0431\u0438\u0442\u0430 \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <strong>x:0..2^kl-1 to 0..m-1<\/strong><\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c <strong>x = SUM 2^j*x|j<\/strong><\/p>\n<p>\u041a\u0430\u043a \u0438 \u0432\u0441\u044f\u043a\u0430\u044f \u0431\u0443\u043b\u0435\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, <strong>x|j<\/strong> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 <strong>Ux|j<\/strong> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0430 \u043a\u0430\u043a <strong>Ux|j(i,z|j) = SUM x|j(k)(Controlled X(X(i) xor k), z|j)<\/strong><\/p>\n<p>NB. \u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0433\u0435\u0442\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0443\u0442\u0451\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b<\/p>\n<h3>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435?<\/h3>\n<p>\u041c\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u0447\u0442\u043e \u0438\u043c\u0435\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0441\u0435\u043b, \u043c\u043e\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043a\u0443\u0431\u0438\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0440\u0430\u0436\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u044d\u0442\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0447\u0438\u0441\u0435\u043b \u0438\u0437 <strong>0..m-1<\/strong><\/p>\n<ul>\n<li>\n<p><strong>x: 0..lx-1 to 0..m-1<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>y: 0..ly-1 to 0..m-1<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0436\u0435\u043c \u043b\u0438 \u043c\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c &#8212; \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0438\u043b\u0438 \u043d\u0435\u0442 \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439?<\/p>\n<p>\u041f\u0443\u0441\u0442\u044c <strong>k<\/strong> &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 <strong>0..max(lx,ly)-1<\/strong><\/p>\n<p>\u0422\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0440\u0430\u043d\u0435\u0435 \u0434\u043e\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f x \u0438 y \u043d\u0430 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0435\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435<\/p>\n<ul>\n<li>\n<p><strong>x: 0..lx-1 to 0..m-1 lx..2^k-1 to rand(m)<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>y: 0..ly-1 to 0..m-1 ly..2^k-1 to rand(m)<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/p>\n<ul>\n<li>\n<p><strong>Ux(i,z)=(i,z xor x(i))<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>Uy(i,z)=(i,z xor y(i))<\/strong><\/p>\n<\/li>\n<\/ul>\n<h3>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u044e \u0438 \u0441\u0432\u0451\u0440\u043a\u0443<\/h3>\n<p>\u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043b\u044c\u0446\u043e \u0441 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 <strong>op<\/strong> \u0438 \u043f\u0430\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <strong>a<\/strong> \u0438 <strong>b<\/strong>, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0445 \u043a\u043e\u043b\u044c\u0446\u043e \u0432 \u043f\u043e\u043b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.<\/p>\n<p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0441\u0432\u0451\u0440\u043a\u0438 <strong>a<\/strong> \u0438 <strong>b<\/strong> \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>c = a x b<\/strong>, \u0442\u0430\u043a\u0443\u044e \u0447\u0442\u043e <strong>c(i) = SUB a(ix)b(iy)|i=ix op iy<\/strong><\/p>\n<p>\u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043b\u044c\u0446\u043e \u0441 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 <strong>op<\/strong> \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>f<\/strong>, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0445 \u043a\u043e\u043b\u044c\u0446\u043e \u0432 \u043f\u043e\u043b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.<\/p>\n<p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>inv f<\/strong> , \u0442\u0430\u043a\u0443\u044e \u0447\u0442\u043e <strong>(inv f)(i) = f( -i )<\/strong>, \u0433\u0434\u0435 <strong>i op -i == 0<\/strong><\/p>\n<p>\u0421\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c <strong>a<\/strong> \u0438 <strong>b<\/strong> \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 <strong>(a,b) = SUM a(i)b(i)<\/strong> (=<strong>(a,b)(0)<\/strong> \u0433\u0434\u0435 <strong>(a,b)(i) = SUM a(ix)b(iy)|i=ix-iy<\/strong>)<\/p>\n<p>\u041b\u0435\u0433\u043a\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e <strong>(a,b) = a x (inv b)<\/strong><\/p>\n<p>\u041f\u0443\u0441\u0442\u044c \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 <strong>a<\/strong> \u0438 <strong>b<\/strong><\/p>\n<ul>\n<li>\n<p><strong>a = SUM A(i)|i><\/strong><\/p>\n<\/li>\n<li>\n<p><strong>b = SUM B(i)|i><\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u043e\u0433\u0434\u0430, \u0435\u0441\u043b\u0438 <strong>op<\/strong>:<\/p>\n<ul>\n<li>\n<p>xor: <strong>(a,b)(i) = SUM A(ix)B(iy)|i>|i=ix xor ~iy<\/strong><\/p>\n<\/li>\n<li>\n<p>add: <strong>(a,b)(i) = SUM A(ix)B(iy)|i>|i=ix + (-iy)<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f <strong>a<\/strong> \u0438 <strong>b<\/strong>?<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 &#8212; \u0430\u0441\u043b\u0438 <strong>A(i)~=B(i)<\/strong> \u0434\u043b\u044f \u0432\u0441\u0435\u0445 <strong>i<\/strong> \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u044b \u043e\u0442 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0445, \u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>(a,b)(0)<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c (\u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e) \u0441\u0440\u0435\u0434\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<br \/> \u0410 \u0437\u043d\u0430\u0447\u0438\u0442, \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043f\u0430\u0440\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043a\u0443\u0431\u0438\u0442\u043e\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0434\u0432\u0443\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439, \u0442\u043e<\/p>\n<ol>\n<li>\n<p>\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u0451\u0440\u0442\u043a\u0438 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432,<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>|0><\/strong> \u0438\u043c\u0435\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c,<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u043e\u0442\u0432\u0435\u0442, \u0447\u0442\u043e \u0434\u0432\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442.<\/p>\n<\/li>\n<\/ol>\n<p>\u0430 \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 &#8212; \u0442\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u043e\u043d\u0443\u0441\u0430 &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>|j><\/strong>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u043c\u0435\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 &#171;\u0441\u0434\u0432\u0438\u0433\u043e\u043c&#187; \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0433\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u043c\u0441\u044f \u043a\u043b\u044e\u0447\u043e\u043c, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u043e\u043c \u0448\u0438\u0444\u0440\u0430).<\/p>\n<p>\u041a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043a\u0443\u0431\u0438\u0442\u043e\u0432?<\/p>\n<p>\u0412\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u043e &#8212; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f <strong>xor<\/strong> &#8212; \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f <strong>scalar(a,b)=(a,a xor X(b))<\/strong>, \u0430 \u0434\u043b\u044f <strong>add<\/strong> &#8212; <strong>scalar(a,b)=(a, a add X(b) add |1>)<\/strong><\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f <a href=\"https:\/\/drive.google.com\/file\/d\/1KIl4LVzPNoPKOQoURHmkVilz_Czxe4tC\/view?usp=sharing\" rel=\"noopener noreferrer nofollow\">\u0441\u0445\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/a><\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/post_images\/a5f\/349\/43f\/a5f34943fd7c9e1215d11b8ffd4cf985.png\" alt=\"\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a5f\/349\/43f\/a5f34943fd7c9e1215d11b8ffd4cf985.png\"\/><\/p>\n<div><figcaption>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439<\/figcaption><\/div>\n<\/figure>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 Q-sharp \u0438 \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/h3>\n<ol>\n<li>\n<p>\u041d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p>\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430) \u043a\u0443\u0431\u0438\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 (\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432) \u043a\u0443\u0431\u0438\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430) \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430<\/p>\n<\/li>\n<li>\n<p>\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430) \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 (xor)<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043a\u0443\u0431\u0438\u0442\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<pre><code>    \/\/\/ # \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     \/\/\/ \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 |abcde...> -> |a+b+c+d+e+...>     \/\/\/ \u042d\u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u0430\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u043d\u043e \u0441\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0434\u043b\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f     operation Sum(qubits: Qubit[], register: Qubit[]) : Unit {         for q in qubits {             Controlled Inc([q], register);         }     }          \/\/\/ # \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 i = ResultArrayAsInt(results);         return i;     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\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 xor value>     operation Xor(target: Qubit[], value: Int) : Unit {         let n = Length(target);         let bools = IntAsBoolArray(value, n);         for idx in 0..n-1 {             if(bools[idx]) {                 X(target[idx]);             }         }     }      \/\/\/ # \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]);         }     } <\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p>\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441 \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c\u043c (\u0438 xor \u0441\u0434\u0432\u0438\u0433 \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443)<\/p>\n<\/li>\n<li>\n<p>\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0432\u043d\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c<\/p>\n<\/li>\n<\/ul>\n<pre><code>    \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \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, \u0442\u043e \u0435\u0441\u0442\u044c n -> SUM SQRT(C(k,n))|k>     operation Binom(n: Int, register: Qubit[]) : Unit {         use qubits = Qubit[n] {             ApplyToEach(H, qubits);             Sum(qubits, register);             ResetAll(qubits);         }     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 0..m-1     \/\/\/ \u0420\u0430\u0432\u043d\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435     operation RandomRandom(m: Int) : Int {         let k = BitSizeI(m-1);         mutable i = 0;         repeat {             use qubits = Qubit[k] {                 ApplyToEach(H, qubits);                 set i = Measure(qubits);                 ResetAll(qubits);             }         }         until (0&lt;=i and i&lt;m);         return i;     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 0..m-1     \/\/\/ \u0411\u0438\u043d\u043e\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435     \/\/\/ \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435     operation RandomBinom(a: Int, m: Int) : Int {         let k = BitSizeI(m-1);         use register = Qubit[k] {             Binom(m-1, register);              let i = Measure(register);             ResetAll(register);             return Microsoft.Quantum.Bitwise.Xor(i,a)  % m;         }     } <\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p>\u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 Ux \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443 x<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u041c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e (\u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0433\u043e) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ul>\n<pre><code>    \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0447\u0438\u0441\u0435\u043b 0..m-1     operation U(m: Int, l: Int, x: Int[], z: Qubit[]) : Unit {         let kl = BitSizeI(l-1);         let km = Length(z);         let total = 2^kl;          use (index) = (Qubit[kl]) {             ApplyToEach(H, index);             for i in 0..total-1 {                 Xor(index, i);                 mutable value = 0;                 if(i &lt; l) {                     set value = x[i];                 }                 else {                     set value = RandomRandom(m);                 }                 let bools = IntAsBoolArray(value, km);                 for j in 0..km-1 {                     if(bools[j]) {                         Controlled X(index, z[j]);                     }                 }                 Xor(index, i);             }             ResetAll(index);         }     }          \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043a\u0443\u0431\u0438\u0442\u043e\u0432     operation ScalarTransformation(a: Qubit[], b: Qubit[]) : Unit     {         let n = Length(a);         ApplyToEach(X, b);         for i in 0..n-1 {             Controlled X([a[i]], b[i]);         }     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0447\u0438\u0441\u0435\u043b     operation IndexOfMax(arr: Int[]) : Int {         mutable result = 0;         let n = Length(arr);         for i in 1..n-1 {             if(arr[result]&lt;arr[i]) {                 set result = i;             }         }         return result;     }       \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u041c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0432\u0443\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432     \/\/\/ \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u043b\u0443\u0447\u0448\u0435\u0433\u043e (\u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u043e\u044f\u0442\u043d\u043e\u0433\u043e) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f     operation TestArrays(m: Int, x: Int[], y: Int[], tests: Int): (Int, Int[]) {         let lx = Length(x);         let ly = Length(y);         mutable l = lx;         if(ly>lx) {             set l = ly;         }         let kl = BitSizeI(l-1);         let km = BitSizeI(m-1);         let s = 2^km;          \/\/ \u0410\u043b\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0447\u0451\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u0441\u0445\u043e\u0434\u043e\u0432 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432         mutable arr = [0, size = s];                  for _ in 1..tests {             use (a, b) = (Qubit[km], Qubit[km]){                                  U(m, l, x, a);                 U(m, l, y, b);                  ScalarTransformation(a, b);                  let i = Measure(b);                                  \/\/ \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0441\u0447\u0451\u0442\u0447\u0438\u043a                 set arr w\/= i &lt;- arr[i] + 1;                                  ResetAll(a);                 ResetAll(b);             }          }         return (IndexOfMax(arr), arr);     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u041c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432     \/\/\/ \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u0435\u043b     \/\/\/ \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u043b\u0443\u0447\u0448\u0435\u0433\u043e (\u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u043e\u044f\u0442\u043d\u043e\u0433\u043e) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f      operation Test(m: Int, randX: (Int)=>Int, randY: (Int)=>Int, l: Int, tests: Int) : (Int, Int[]) {         mutable x = [0, size = l];         mutable y = [0, size = l];          for i in 0..l-1 {             set x w\/= i &lt;- randX(m);         }         for i in 0..l-1 {             set y w\/= i &lt;- randY(m);         }                  Message($\"x = {x} \/ y = {y}\");          return TestArrays(m, x, y, tests);     } <\/code><\/pre>\n<ol start=\"4\">\n<li>\n<p>\u0418, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0430\u043c \u0442\u0435\u0441\u0442 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430<\/p>\n<\/li>\n<\/ol>\n<pre><code>    @EntryPoint()     operation Main(n: Int, l: Int, t: Int) : Unit {         let m=2^n;          Message(\"Hello quantum world!\");         Message($\"Binom0\/Binom0: {Test(m, RandomBinom(0,_), RandomBinom(0,_), l, t)}\");         Message($\"Binom0\/Binom1: {Test(m, RandomBinom(0,_), RandomBinom(1,_), l, t)}\");         Message($\"Binom3\/Binom1: {Test(m, RandomBinom(3,_), RandomBinom(1,_), l, t)}\");         Message($\"Binom0\/Random: {Test(m, RandomBinom(0,_), RandomRandom, l, t)}\");         Message($\"Random\/Random: {Test(m, RandomRandom, RandomRandom, l, t)}\");         Message($\"Random\/Binom0: {Test(m, RandomRandom, RandomBinom(0,_), l, t)}\");     } <\/code><\/pre>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0437\u044f\u0442\u044c \u0437\u0434\u0435\u0441\u044c <a href=\"https:\/\/github.com\/dprotopopov\/qcompare\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/dprotopopov\/qcompare<\/a><\/p>\n<h3>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 &#8230;<\/h3>\n<pre><code>PS C:\\Projects\\qcompare> dotnet run -n 3 -l 32 -t 100 Hello quantum world! x = [7,6,5,4,2,3,3,3,2,4,4,5,6,3,4,4,5,4,4,4,5,4,3,4,5,4,5,4,6,3,2,3] \/ y = [2,5,1,2,2,3,6,6,3,2,1,5,5,5,3,3,6,5,2,4,4,6,6,2,4,5,5,4,4,4,3,3] Binom0\/Binom0: (7, [15,16,16,6,4,10,15,18]) x = [4,5,6,3,5,3,2,5,7,6,3,4,5,1,2,1,4,2,4,2,1,4,4,2,2,6,2,3,3,5,4,3] \/ y = [4,5,4,2,3,2,4,5,0,3,1,2,4,2,4,5,3,2,2,5,2,3,5,2,2,2,2,2,5,7,2,3] Binom0\/Binom1: (1, [14,21,9,18,3,6,16,13]) x = [3,5,7,5,6,1,1,7,1,7,6,1,1,7,7,1,1,0,7,0,6,1,1,6,6,4,6,1,0,0,6,7] \/ y = [2,5,5,2,2,4,0,5,3,2,5,7,4,5,2,0,5,5,5,0,2,5,2,0,2,3,2,4,4,0,5,4] Binom3\/Binom1: (2, [9,6,24,20,18,10,10,3]) x = [6,4,4,2,2,3,3,4,3,4,2,3,3,4,3,4,4,3,4,2,3,5,4,2,5,4,4,3,3,3,5,5] \/ y = [6,6,0,2,4,1,2,5,3,1,0,2,4,4,3,3,5,0,1,6,3,2,1,3,2,1,0,0,5,7,4,0] Binom0\/Random: (1, [13,16,11,15,7,9,15,14]) x = [4,4,3,4,4,1,3,7,5,6,1,3,1,4,0,1,5,4,0,0,1,2,4,5,5,0,0,4,2,6,7,3] \/ y = [4,6,7,5,2,4,5,2,6,6,5,7,0,4,3,0,5,3,0,1,7,3,6,7,6,7,0,7,4,1,5,1] Random\/Random: (3, [11,10,11,21,9,10,18,10]) x = [7,2,3,3,5,7,4,4,3,0,2,0,5,3,0,4,7,6,6,7,7,6,2,4,2,6,7,4,0,0,0,4] \/ y = [5,3,5,5,4,3,3,4,3,3,2,5,3,3,3,2,4,3,5,3,4,6,2,4,4,3,4,3,4,3,3,5] Random\/Binom0: (7, [10,15,10,15,14,7,12,17]) <\/code><\/pre>\n<p>\u0412\u0440\u043e\u0434\u0435 \u0432\u0441\u0451 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e &#8230;<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435. \u0422\u043e, \u0447\u0442\u043e Binom0\/Binom0 \u0441\u043e\u0432\u043f\u0430\u043b\u043e \u0441\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c 7 &#8212; \u0442\u043e \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0431\u0438\u043d\u043e\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e, \u0442\u043e \u0435\u0441\u0442\u044c \u0421(k, 7) = C(k xor 7, 7)<\/p>\n<h3>\u0421\u0441\u044b\u043b\u043a\u0438<\/h3>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/dprotopopov\/qcompare\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/dprotopopov\/qcompare<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/learn.microsoft.com\/ru-ru\/azure\/quantum\/user-guide\/host-programs?tabs=tabid-copilot\" rel=\"noopener noreferrer nofollow\">https:\/\/learn.microsoft.com\/ru-ru\/azure\/quantum\/user-guide\/host-programs?tabs=tabid-copilot<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/learn.microsoft.com\/ru-ru\/training\/modules\/qsharp-create-first-quantum-development-kit\/2-install-quantum-development-kit-code\" rel=\"noopener noreferrer nofollow\">https:\/\/learn.microsoft.com\/ru-ru\/training\/modules\/qsharp-create-first-quantum-development-kit\/2-install-quantum-development-kit-code<\/a><\/p>\n<\/li>\n<\/ul>\n<h3>\u0420\u0430\u043d\u0435\u0435 \u043f\u0440\u043e \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/h3>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/p\/768666\/\" rel=\"noopener noreferrer nofollow\">\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<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/p\/766512\/\" rel=\"noopener noreferrer nofollow\">\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><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/p\/759352\/\" rel=\"noopener noreferrer nofollow\">\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><\/p>\n<\/li>\n<\/ul>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0432\u0451\u0440\u0442\u043a\u0438 \u0432 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445<\/h3>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/p\/266129\/\" rel=\"noopener noreferrer nofollow\">\u0424\u0443\u0440\u044c\u0435-\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/p\/597715\/\" rel=\"noopener noreferrer nofollow\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0441\u0435\u0440\u0434\u0435\u0447\u043d\u044b\u0445 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u0445 \u0424\u0443\u0440\u044c\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439<\/a><\/p>\n<\/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\/769148\/\"> https:\/\/habr.com\/ru\/articles\/769148\/<\/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-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"\"><\/figure>\n<p>\u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u043e\u0432\u044b\u0439 \u043c\u0438\u0440 \u043d\u043e\u0432\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439!<\/p>\n<p>\u0412 \u0431\u044b\u0442\u0443, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b, \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u044c &#8212; \u043f\u043e\u0445\u043e\u0436\u0438 \u043b\u0438 \u043e\u043d\u0438 \u0438\u043b\u0438 \u043d\u0435\u0442, \u0438 \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0438 \u043f\u043e\u0445\u043e\u0436\u0438.<\/p>\n<p>\u0422\u0430\u043a \u0438 \u0432 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435 &#8212; \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0447\u0438\u0441\u0435\u043b, \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u044c &#8212; \u043f\u043e\u0445\u043e\u0436\u0438 \u043b\u0438 \u043e\u043d\u0438 \u0438\u043b\u0438 \u043d\u0435\u0442, \u0438 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0438 \u043f\u043e\u0445\u043e\u0436\u0438.<\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 &#171;\u043f\u043e\u0445\u043e\u0436\u0435\u0441\u0442\u0438&#187; \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u044d\u0442\u0438\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043a\u0443-\u0442\u0435\u0441\u0442 \u043d\u0430 Q-sharp \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u044d\u0442\u0438\u0445 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043f\u043e<\/p>\n<ul>\n<li>\n<p>\u0442\u0435\u043e\u0440\u0438\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438<\/p>\n<\/li>\n<li>\n<p>\u0430\u043b\u0433\u0435\u0431\u0440\u0435<\/p>\n<\/li>\n<li>\n<p>\u0431\u0443\u043b\u0435\u0432\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c<\/p>\n<\/li>\n<li>\n<p>\u0441\u0432\u0451\u0440\u0442\u043a\u0435, \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438, \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044e<\/p>\n<\/li>\n<li>\n<p>\u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c (\u043a\u0443\u0431\u0438\u0442\u044b \u0438 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438)<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043d\u0430 Q-sharp<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>\u041f\u0443\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c <strong>x(i)<\/strong> \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0438\u0437 <strong>0..m-1<\/strong>, \u0433\u0434\u0435 <strong>i=0..l-1<\/strong><\/p>\n<p>\u0421\u043f\u0440\u043e\u0441\u0438\u043c \u0441\u0435\u0431\u044f &#8212; \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u043c\u0430\u0441\u0441\u0438\u0432\u0430) \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 <strong>SUM SQRT(P(v))|v><\/strong>, \u0433\u0434\u0435 <strong>P(v)<\/strong> &#8212; \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 <strong>v<\/strong> \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <strong>x(i)<\/strong>?<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 &#8212; \u0430 \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0438 \u043d\u0435\u0442 (\u043d\u043e \u0441 \u043e\u0433\u043e\u0432\u043e\u0440\u043a\u0430\u043c\u0438)!<\/p>\n<p>\u0427\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c <strong>x(i)<\/strong>, \u0433\u0434\u0435 <strong>i=0..l-1<\/strong> ?<\/p>\n<p>\u042d\u0442\u043e \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (\u0444\u0443\u043d\u043a\u0446\u0438\u044f) <strong>x: 0..l-1 to 0..m-1<\/strong><\/p>\n<p>\u041f\u0443\u0441\u0442\u044c<\/p>\n<p><strong>kl<\/strong> &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b <strong>0..l-1<\/strong><br \/> <strong>km<\/strong> &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b <strong>0..m-1<\/strong><\/p>\n<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <strong>x: 0..l-1 to 0..m-1<\/strong> \u0432 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 <strong>Ux(i,z)=(i,z xor x(i))<\/strong><br \/> \u0433\u0434\u0435 <strong>i<\/strong> &#8212; \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0438\u0437 <strong>kl<\/strong> \u043a\u0443\u0431\u0438\u0442\u043e\u0432, \u0430 <strong>z<\/strong> &#8212; \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0438\u0437 <strong>km<\/strong> \u043a\u0443\u0431\u0438\u0442\u043e\u0432<\/p>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e <strong>Ux(H|0>,|0>)<\/strong>, \u0442\u043e (\u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <strong>i<\/strong> \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 <strong>0..2^kl-1<\/strong>) \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <strong>z<\/strong> \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041d\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>x<\/strong> \u043d\u0430 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 <strong>l..2^kl-1<\/strong>.<\/p>\n<p>\u0415\u0441\u0442\u044c \u043b\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f? \u041a\u043e\u043d\u0435\u0447\u043d\u043e!<\/p>\n<p>\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 &#8212; \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0443\u0447\u0430\u0441\u0442\u043a\u0435 <strong>l..2^kl-1<\/strong> \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0440\u0430\u0432\u043d\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0438\u0437 <strong>0..m-1<\/strong><\/p>\n<p>\u0418 \u0432\u0443\u0430\u043b\u044f &#8230;<\/p>\n<p>\u0418\u043c\u0435\u0435\u043c <strong>x:0..2^kl-1 to 0..m-1<\/strong> \u0438 <strong>Ux(i,z)=(i,z xor x(i))<\/strong><\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u0434\u0430\u0451\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 <strong>(i,z)=(H|0>,|0>)<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e <strong>Ux<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0418 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <strong>z<\/strong> \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043d\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u0440\u0435\u0434\u043d\u0451\u043d\u043d\u044b\u0435, \u0437\u0430 \u0441\u0447\u0451\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0445\u0432\u043e\u0441\u0442\u0430 \u0438\u0437 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0440\u0430\u0432\u043d\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b)<\/p>\n<\/li>\n<\/ol>\n<h3>\u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 Ux ?<\/h3>\n<p>\u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0433\u0435\u0439\u0442\u043e\u0432 &#8212; <strong>X<\/strong> \u0438 <strong>Controlled X<\/strong><\/p>\n<p>\u041f\u0443\u0441\u0442\u044c <strong>x|j:0..2^kl-1 to 0..1<\/strong> &#8212; \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0432\u0437\u044f\u0442\u0438\u0435\u043c <strong>j<\/strong>-\u0433\u043e \u0431\u0438\u0442\u0430 \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <strong>x:0..2^kl-1 to 0..m-1<\/strong><\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c <strong>x = SUM 2^j*x|j<\/strong><\/p>\n<p>\u041a\u0430\u043a \u0438 \u0432\u0441\u044f\u043a\u0430\u044f \u0431\u0443\u043b\u0435\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, <strong>x|j<\/strong> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 <strong>Ux|j<\/strong> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0430 \u043a\u0430\u043a <strong>Ux|j(i,z|j) = SUM x|j(k)(Controlled X(X(i) xor k), z|j)<\/strong><\/p>\n<p>NB. \u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0433\u0435\u0442\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0443\u0442\u0451\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b<\/p>\n<h3>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435?<\/h3>\n<p>\u041c\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u0447\u0442\u043e \u0438\u043c\u0435\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0441\u0435\u043b, \u043c\u043e\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043a\u0443\u0431\u0438\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0440\u0430\u0436\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u044d\u0442\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0447\u0438\u0441\u0435\u043b \u0438\u0437 <strong>0..m-1<\/strong><\/p>\n<ul>\n<li>\n<p><strong>x: 0..lx-1 to 0..m-1<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>y: 0..ly-1 to 0..m-1<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0436\u0435\u043c \u043b\u0438 \u043c\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c &#8212; \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0438\u043b\u0438 \u043d\u0435\u0442 \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439?<\/p>\n<p>\u041f\u0443\u0441\u0442\u044c <strong>k<\/strong> &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 <strong>0..max(lx,ly)-1<\/strong><\/p>\n<p>\u0422\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0440\u0430\u043d\u0435\u0435 \u0434\u043e\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f x \u0438 y \u043d\u0430 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0435\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435<\/p>\n<ul>\n<li>\n<p><strong>x: 0..lx-1 to 0..m-1 lx..2^k-1 to rand(m)<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>y: 0..ly-1 to 0..m-1 ly..2^k-1 to rand(m)<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/p>\n<ul>\n<li>\n<p><strong>Ux(i,z)=(i,z xor x(i))<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>Uy(i,z)=(i,z xor y(i))<\/strong><\/p>\n<\/li>\n<\/ul>\n<h3>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u044e \u0438 \u0441\u0432\u0451\u0440\u043a\u0443<\/h3>\n<p>\u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043b\u044c\u0446\u043e \u0441 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 <strong>op<\/strong> \u0438 \u043f\u0430\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <strong>a<\/strong> \u0438 <strong>b<\/strong>, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0445 \u043a\u043e\u043b\u044c\u0446\u043e \u0432 \u043f\u043e\u043b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.<\/p>\n<p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0441\u0432\u0451\u0440\u043a\u0438 <strong>a<\/strong> \u0438 <strong>b<\/strong> \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>c = a x b<\/strong>, \u0442\u0430\u043a\u0443\u044e \u0447\u0442\u043e <strong>c(i) = SUB a(ix)b(iy)|i=ix op iy<\/strong><\/p>\n<p>\u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043b\u044c\u0446\u043e \u0441 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 <strong>op<\/strong> \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>f<\/strong>, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0445 \u043a\u043e\u043b\u044c\u0446\u043e \u0432 \u043f\u043e\u043b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.<\/p>\n<p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>inv f<\/strong> , \u0442\u0430\u043a\u0443\u044e \u0447\u0442\u043e <strong>(inv f)(i) = f( -i )<\/strong>, \u0433\u0434\u0435 <strong>i op -i == 0<\/strong><\/p>\n<p>\u0421\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c <strong>a<\/strong> \u0438 <strong>b<\/strong> \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 <strong>(a,b) = SUM a(i)b(i)<\/strong> (=<strong>(a,b)(0)<\/strong> \u0433\u0434\u0435 <strong>(a,b)(i) = SUM a(ix)b(iy)|i=ix-iy<\/strong>)<\/p>\n<p>\u041b\u0435\u0433\u043a\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e <strong>(a,b) = a x (inv b)<\/strong><\/p>\n<p>\u041f\u0443\u0441\u0442\u044c \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 <strong>a<\/strong> \u0438 <strong>b<\/strong><\/p>\n<ul>\n<li>\n<p><strong>a = SUM A(i)|i><\/strong><\/p>\n<\/li>\n<li>\n<p><strong>b = SUM B(i)|i><\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u043e\u0433\u0434\u0430, \u0435\u0441\u043b\u0438 <strong>op<\/strong>:<\/p>\n<ul>\n<li>\n<p>xor: <strong>(a,b)(i) = SUM A(ix)B(iy)|i>|i=ix xor ~iy<\/strong><\/p>\n<\/li>\n<li>\n<p>add: <strong>(a,b)(i) = SUM A(ix)B(iy)|i>|i=ix + (-iy)<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f <strong>a<\/strong> \u0438 <strong>b<\/strong>?<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 &#8212; \u0430\u0441\u043b\u0438 <strong>A(i)~=B(i)<\/strong> \u0434\u043b\u044f \u0432\u0441\u0435\u0445 <strong>i<\/strong> \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u044b \u043e\u0442 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0445, \u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>(a,b)(0)<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c (\u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e) \u0441\u0440\u0435\u0434\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<br \/> \u0410 \u0437\u043d\u0430\u0447\u0438\u0442, \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043f\u0430\u0440\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043a\u0443\u0431\u0438\u0442\u043e\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0434\u0432\u0443\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439, \u0442\u043e<\/p>\n<ol>\n<li>\n<p>\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u0451\u0440\u0442\u043a\u0438 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432,<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>|0><\/strong> \u0438\u043c\u0435\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c,<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u043e\u0442\u0432\u0435\u0442, \u0447\u0442\u043e \u0434\u0432\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442.<\/p>\n<\/li>\n<\/ol>\n<p>\u0430 \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 &#8212; \u0442\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u043e\u043d\u0443\u0441\u0430 &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>|j><\/strong>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u043c\u0435\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 &#171;\u0441\u0434\u0432\u0438\u0433\u043e\u043c&#187; \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0433\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u043c\u0441\u044f \u043a\u043b\u044e\u0447\u043e\u043c, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u043e\u043c \u0448\u0438\u0444\u0440\u0430).<\/p>\n<p>\u041a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043a\u0443\u0431\u0438\u0442\u043e\u0432?<\/p>\n<p>\u0412\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u043e &#8212; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f <strong>xor<\/strong> &#8212; \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f <strong>scalar(a,b)=(a,a xor X(b))<\/strong>, \u0430 \u0434\u043b\u044f <strong>add<\/strong> &#8212; <strong>scalar(a,b)=(a, a add X(b) add |1>)<\/strong><\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f <a href=\"https:\/\/drive.google.com\/file\/d\/1KIl4LVzPNoPKOQoURHmkVilz_Czxe4tC\/view?usp=sharing\" rel=\"noopener noreferrer nofollow\">\u0441\u0445\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/a><\/p>\n<figure class=\"\">\n<div><figcaption>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439<\/figcaption><\/div>\n<\/figure>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 Q-sharp \u0438 \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/h3>\n<ol>\n<li>\n<p>\u041d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p>\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430) \u043a\u0443\u0431\u0438\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 (\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432) \u043a\u0443\u0431\u0438\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430) \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430<\/p>\n<\/li>\n<li>\n<p>\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430) \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 (xor)<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043a\u0443\u0431\u0438\u0442\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<pre><code>    \/\/\/ # \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     \/\/\/ \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 |abcde...> -> |a+b+c+d+e+...>     \/\/\/ \u042d\u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u0430\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u043d\u043e \u0441\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0434\u043b\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f     operation Sum(qubits: Qubit[], register: Qubit[]) : Unit {         for q in qubits {             Controlled Inc([q], register);         }     }          \/\/\/ # \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 i = ResultArrayAsInt(results);         return i;     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\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 xor value>     operation Xor(target: Qubit[], value: Int) : Unit {         let n = Length(target);         let bools = IntAsBoolArray(value, n);         for idx in 0..n-1 {             if(bools[idx]) {                 X(target[idx]);             }         }     }      \/\/\/ # \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]);         }     } <\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p>\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 \u043a\u0443\u0431\u0438\u0442\u043e\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441 \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c\u043c (\u0438 xor \u0441\u0434\u0432\u0438\u0433 \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443)<\/p>\n<\/li>\n<li>\n<p>\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0432\u043d\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c<\/p>\n<\/li>\n<\/ul>\n<pre><code>    \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \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, \u0442\u043e \u0435\u0441\u0442\u044c n -> SUM SQRT(C(k,n))|k>     operation Binom(n: Int, register: Qubit[]) : Unit {         use qubits = Qubit[n] {             ApplyToEach(H, qubits);             Sum(qubits, register);             ResetAll(qubits);         }     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 0..m-1     \/\/\/ \u0420\u0430\u0432\u043d\u043e\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435     operation RandomRandom(m: Int) : Int {         let k = BitSizeI(m-1);         mutable i = 0;         repeat {             use qubits = Qubit[k] {                 ApplyToEach(H, qubits);                 set i = Measure(qubits);                 ResetAll(qubits);             }         }         until (0&lt;=i and i&lt;m);         return i;     }      \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 0..m-1     \/\/\/ \u0411\u0438\u043d\u043e\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435     \/\/\/ \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435     operation RandomBinom(a: Int, m: Int) : Int {         let k = BitSizeI(m-1);         use register = Qubit[k] {             Binom(m-1, register);              let i = Measure(register);             ResetAll(register);             return Microsoft.Quantum.Bitwise.Xor(i,a)  % m;         }     } <\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p>\u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 Ux \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443 x<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u041c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e (\u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0433\u043e) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ul>\n<pre><code>    \/\/\/ # \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435     \/\/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0447\u0438\u0441\u0435\u043b 0..m-1     operation U(m: Int, l: Int, x: Int[], z: Qubit[]) : Unit {         let kl = BitSizeI(l-1);         let km = Length(z);         let total = 2^kl;          use (index) = (Qubit[kl]) {             ApplyToEach(H, index);             for i in<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-358158","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358158","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=358158"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358158\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=358158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=358158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=358158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}