{"id":302,"date":"2020-07-03T21:44:00","date_gmt":"2020-07-03T12:44:00","guid":{"rendered":"http:\/\/attacktube.com\/?p=302"},"modified":"2022-12-20T22:28:50","modified_gmt":"2022-12-20T13:28:50","slug":"c%e8%a8%80%e8%aa%9e-%e5%86%8d%e5%b8%b0%e9%96%a2%e6%95%b0%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e6%9c%80%e5%a4%a7%e5%80%a4%e3%81%a8%e6%9c%80%e5%b0%8f%e5%80%a4%e3%81%ae%e6%b1%82%e3%82%81%e6%96%b9-2","status":"publish","type":"post","link":"https:\/\/attacktube.com\/?p=302","title":{"rendered":"\u3010C\u8a00\u8a9e\u3011 \u518d\u5e30\u95a2\u6570\u3092\u4f7f\u3063\u305f\u6700\u5927\u5024\u3068\u6700\u5c0f\u5024\u306e\u6c42\u3081\u65b9(\u30c7\u30fc\u30bf\u306e\u6570\u304c2\u306e\u3079\u304d\u4e57\u9650\u5b9a)"},"content":{"rendered":"\n<p>\u30c7\u30fc\u30bf\u3092\u914d\u5217\u306b\u5165\u308c\u3066box=[1,2,3,\u30fb\u30fb\u30fb]\u3068\u3057\u3066\u6700\u5927\u5024\u3092\u6c42\u3081\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n\n\n\n<p>1.\u30c7\u30fc\u30bf\u6570\u304c1\u306e\u3068\u304d\u3001box[0]\u304c\u6700\u5927\u5024\u3068\u306a\u308b<br>2.\u30c7\u30fc\u30bf\u6570\u304c2\u306e\u3068\u304d\u3001box[0]\u3092\u30b0\u30eb\u30fc\u30d71\u3068\u3057box[1]\u3092\u30b0\u30eb\u30fc\u30d72\u3068\u3057\u3066\u3001\u30b0\u30eb\u30fc\u30d71\u306e\u6700\u5927\u5024\u3068\u30b0\u30eb\u30fc\u30d72\u306e\u6700\u5927\u5024\u3092\u6bd4\u8f03\u3057<br>\u5927\u304d\u3044\u65b9\u304c\u30c7\u30fc\u30bf\u306e\u6700\u5927\u5024\u3068\u306a\u308b\u3002<br>3.\u30c7\u30fc\u30bf\u6570\u304c4\u306e\u3068\u304d box[0]\uff5ebox[1]\u3092\u30b0\u30eb\u30fc\u30d71\u3068\u3057box[2]\uff5ebox[3]\u3092\u30b0\u30eb\u30fc\u30d72\u3068\u3057\u3066\u30b0\u30eb\u30fc\u30d71\u306e\u6700\u5927\u5024\u3068\u30b0\u30eb\u30fc\u30d72\u306e\u6700\u5927\u5024\u3092\u6bd4\u8f03\u3057<br>\u5927\u304d\u3044\u65b9\u304c\u30c7\u30fc\u30bf\u306e\u6700\u5927\u5024\u3068\u306a\u308b\u3002<br>4.\u30c7\u30fc\u30bf\u6570\u304c8\u306e\u3068\u304d\u3001box[0]\uff5ebox[3]\u3092\u30b0\u30eb\u30fc\u30d71\u3068\u3057box[4]\uff5ebox[7]\u3092\u30b0\u30eb\u30fc\u30d72\u3068\u3057\u3066\u30b0\u30eb\u30fc\u30d71\u306e\u6700\u5927\u5024\u3068\u30b0\u30eb\u30fc\u30d72\u306e\u6700\u5927\u5024\u3092\u6bd4\u8f03\u3057<br>\u5927\u304d\u3044\u65b9\u304c\u30c7\u30fc\u30bf\u306e\u6700\u5927\u5024\u3068\u306a\u308b\u3002<br>5.\u30c7\u30fc\u30bf\u6570\u304c16\u306e\u3068\u304d\u3001box[0]\uff5ebox[7]\u3092\u30b0\u30eb\u30fc\u30d71\u3068\u3057box[8]\uff5ebox[16]\u3092\u30b0\u30eb\u30fc\u30d72\u3068\u3057\u3066\u30b0\u30eb\u30fc\u30d71\u306e\u6700\u5927\u5024\u3068\u30b0\u30eb\u30fc\u30d72\u306e\u6700\u5927\u5024\u3092\u6bd4\u8f03\u3057<br>\u5927\u304d\u3044\u65b9\u304c\u30c7\u30fc\u30bf\u306e\u6700\u5927\u5024\u3068\u306a\u308b\u3002<br>6.\u30c7\u30fc\u30bf\u6570\u304c32\u306e\u3068\u304d\u3001box[0]\uff5ebox[15]\u3092\u30b0\u30eb\u30fc\u30d71\u3068\u3057box[16]\uff5ebox[32]\u3092\u30b0\u30eb\u30fc\u30d72\u3068\u3057\u3066\u30b0\u30eb\u30fc\u30d71\u306e\u6700\u5927\u5024\u3068\u30b0\u30eb\u30fc\u30d72\u306e\u6700\u5927\u5024\u3092\u6bd4\u8f03\u3057<br>\u5927\u304d\u3044\u65b9\u304c\u30c7\u30fc\u30bf\u306e\u6700\u5927\u5024\u3068\u306a\u308b\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306bn(\u30c7\u30fc\u30bf\u304c2\u306e\u3079\u304d\u4e57)\u306e\u3068\u304dbox[[0]\uff5ebox[(n\/2)-1]\u3092\u30b0\u30eb\u30fc\u30d71\u3068\u3057box[n\/2]\uff5ebox[n-1]\u3092\u30b0\u30eb\u30fc\u30d72<\/p>\n\n\n\n<p>\u3068\u3057\u3066\u30b0\u30eb\u30fc\u30d71\u306e\u6700\u5927\u5024\u3068\u30b0\u30eb\u30fc\u30d72\u306e\u6700\u5927\u5024\u3092\u6bd4\u8f03\u3057<br>\u5927\u304d\u3044\u65b9\u304c\u30c7\u30fc\u30bf\u306e\u6700\u5927\u5024\u3068\u306a\u308b\u3002<\/p>\n\n\n\n<p>\u6700\u5c0f\u5024\u3082\u540c\u69d8\u306a\u8003\u3048\u65b9\u3067\u3067\u304d\u308b\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<br>\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-3461056110605997\" crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3461056110605997\" data-ad-slot=\"3137443461\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n<br>\n\n\n\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u30bd\u30fc\u30b9\u306f\u4ee5\u4e0b<\/p>\n\n\n\n<pre><code>\n\n\/\/\u6700\u5927\u5024\u3092\u6c42\u3081\u308b(\u30c7\u30fc\u30bf\u306e\u6570\u304c2\u306e\u3079\u304d\u4e57\u9650\u5b9a)\n#include&lt;stdio.h&gt;\n#include&lt;math.h&gt;\nint min(int *, int);\n\nint main()\n{\n\n\u3000int c[] = {1,2,3,4,5,600,7,8,9,10,11,12,16,14,15,13,2,18,1889,20,21,22,23,24,25,26,27,28,29,30,31,32};\n\n\u3000printf(\"\u6700\u5927\u5024:%d\\n\", min(c, 7));\n\n\u3000return 0;\n}\n\n\/\/\u6700\u5927\u5024\u3092\u6c42\u3081\u308b\nint min(int *m, int n)\n{\n\n\u3000\u3000if(n==2){return m[0];}\n\n\u3000\u3000else if(n==3){return (min(m, 2) &lt; min(m+1, 2)) ? min(m+1, 2) :min(m, 2);}\n\n\u3000\u3000else if(n==4){return (min(m, 3) &lt; min(m+2, 3)) ? min(m+2, 3) :min(m, 3);}\n\n\u3000\u3000else if(n==5){return (min(m, 4) &lt; min(m+4, 4)) ? min(m+4, 4) :min(m, 4);}\n\n\u3000\u3000else if(n==6){return (min(m, 5) &lt; min(m+8, 5)) ? min(m+8, 5) :min(m, 5);}\n\n\u3000\u3000else {return (min(m, 6) &lt; min(m+16, 6)) ? min(m+16, 6) :min(m, 6);}\n}\n\n<\/code><\/pre>\n\n\n\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068<\/p>\n\n\n\n<p>C:\\&gt;0515.exe<br>\u6700\u5927\u5024:1889<\/p>\n\n\n\n<p>\u3053\u308c\u3092\u6539\u9020\u3057\u3066\u30c7\u30fc\u30bf\u3092scanf\u3067\u8aad\u307f\u8fbc\u3080\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n\n\n\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u30bd\u30fc\u30b9\u306f\u4ee5\u4e0b<\/p>\n\n\n\n<pre><code>\n\/\/\u6700\u5927\u5024\u3068\u6700\u5c0f\u5024\u3092\u6c42\u3081\u308b\n\/\/\u30c7\u30fc\u30bf\u306f2\u306e\u3079\u304d\u4e57\u306b\u9650\u3089\u308c\u308b\n\/\/scanf\u3067\u30c7\u30fc\u30bf\u3092\u5165\u529b\u3059\u308b\n\/\/\u6700\u5927\u5024\u3068\u6700\u5c0f\u5024\u3092\u6c42\u3081\u308b\u95a2\u6570\u306e\u7b2c2\u5f15\u6570\u306b\u30c7\u30fc\u30bf\u306e\u500b\u6570\u3092\u5e952\u306e\u5bfe\u6570\u3092\u3068\u3063\u30662\u3092\u8db3\u3057\u305f\u5024\u3092\u6e21\u3059\n#include&lt;stdio.h&gt;\n#include&lt;math.h&gt;\nint max_of_array(int *, double);\nint min_of_array(int *, double);\n#define N 400\/\/\u5165\u529b\u3059\u308b\u30c7\u30fc\u30bf\u306e\u6570\u306f400\u4ee5\u4e0b\n\nint main()\n{\n\u3000int kk;\n\n\u3000int box[N],i;\n\n\u3000double pp,n;\n\n\u3000printf(\"\u30c7\u30fc\u30bf\u306e\u6570\u3092\u5165\u529b\u305b\u3088&gt;&gt;\");\n\n\u3000scanf(\"%d\",&amp;kk);\n\n\u3000printf(\"\u30c7\u30fc\u30bf\u30921\u3064\u305a\u3064\u5165\u529b\u305b\u3088\\n\");\n\n\u3000pp=(log(kk)\/log(2));\n\n\u3000for(i=0;i&lt;kk;i++){scanf(\"%d\",&amp;box[i]);}\n\n\u3000printf(\"%d\u306f2\u306e%lf\u4e57\u3067\u3042\u308b\\n\",kk,pp);\n\n\u3000n=pp+2;\n\n\u3000printf(\"\u7b2c2\u5f15\u6570n=%lf\\n\",n);\n\n\u3000printf(\"\u6700\u5927\u5024:%d\\n\", max_of_array(box, n));\n\n\u3000printf(\"\u6700\u5c0f\u5024:%d\\n\", min_of_array(box, n));\n\n\u3000return 0;\n}\n\n\/\/\u6700\u5927\u5024\u3092\u6c42\u3081\u308b\nint max_of_array(int *m, double n)\n{\n\n\u3000int g;\n\n\u3000if(n==2){return m[0];}\n\n\u3000else {g=pow(2,(n-3));\n\n\u3000return (max_of_array(m, n-1) &lt; max_of_array(m+g, n-1)) ? max_of_array(m+g, n-1) :max_of_array(m, n-1);}\n}\n\n\/\/\u6700\u5c0f\u5024\u3092\u6c42\u3081\u308b\nint min_of_array(int *m, double n)\n{\n\n\u3000int g;\n\n\u3000if(n==2){return m[0];}\n\n\u3000else {g=pow(2,(n-3));\n\n\u3000return (min_of_array(m, n-1) &gt; min_of_array(m+g, n-1)) ? min_of_array(m+g, n-1) :min_of_array(m, n-1);}\n}\n\n<\/code><\/pre>\n\n\n\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068<\/p>\n\n\n\n<p>C:\\&gt;0515.exe<br>\u30c7\u30fc\u30bf\u306e\u6570\u3092\u5165\u529b\u305b\u3088&gt;&gt;16<br>\u30c7\u30fc\u30bf\u30921\u3064\u305a\u3064\u5165\u529b\u305b\u3088<br>3<br>53<br>24<br>65<br>33<br>55<br>33<br>75<br>33<br>44<br>663<br>24<br>-8<br>-8<br>55<br>44<br>16\u306f2\u306e4.000000\u4e57\u3067\u3042\u308b<br>\u7b2c2\u5f15\u6570n=6.000000<br>\u6700\u5927\u5024:663<br>\u6700\u5c0f\u5024:-8<\/p>\n\n\n\n<p>\u3053\u306e\u7d50\u679c\u306f\u6b63\u3057\u3044\u3002<\/p>\n\n\n\n<script type=\"text\/javascript\">\njQuery(function($){\n$(\".jp-video\").hide();\n});\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>\u30c7\u30fc\u30bf\u3092\u914d\u5217\u306b\u5165\u308c\u3066box=[1,2,3,\u30fb\u30fb\u30fb]\u3068\u3057\u3066\u6700\u5927\u5024\u3092\u6c42\u3081\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3059\u308b\u3002 1.\u30c7\u30fc\u30bf\u6570\u304c1\u306e\u3068\u304d\u3001box[0]\u304c\u6700\u5927\u5024\u3068\u306a\u308b2.\u30c7\u30fc\u30bf\u6570\u304c2\u306e\u3068\u304d\u3001box[0]\u3092\u30b0\u30eb\u30fc\u30d71\u3068\u3057box[1]\u3092\u30b0\u30eb\u30fc\u30d72 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10],"tags":[],"class_list":["post-302","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/posts\/302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/attacktube.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=302"}],"version-history":[{"count":5,"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/posts\/302\/revisions"}],"predecessor-version":[{"id":402,"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/posts\/302\/revisions\/402"}],"wp:attachment":[{"href":"https:\/\/attacktube.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/attacktube.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/attacktube.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}