{"id":48,"date":"2011-05-03T22:58:18","date_gmt":"2011-05-03T13:58:18","guid":{"rendered":"http:\/\/tech.fuqinho.net\/?p=48"},"modified":"2011-05-03T22:58:18","modified_gmt":"2011-05-03T13:58:18","slug":"%e4%b9%85%e3%81%97%e3%81%b6%e3%82%8a%e3%81%aetopcoder-srm-505-div2","status":"publish","type":"post","link":"https:\/\/tech.fuqinho.net\/?p=48","title":{"rendered":"\u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2)"},"content":{"rendered":"<p>\t\t\t\t\u3082\u306e\u3059\u3054\u304f\u4e45\u3057\u3076\u308a\u306eTopCoder.<\/p>\n<p><strong>250<\/strong><\/p>\n<blockquote><p>\u3042\u308f\u3066\u3093\u307c\u3055\u3093\u304c<br \/>\n&#8220;this is merely an example. be careful. this is a new sentence.&#8221;<br \/>\n\u307f\u305f\u3044\u306b\u982d\u6587\u5b57\u3092\u5927\u6587\u5b57\u306b\u3057\u306a\u3044\u3067\u66f8\u3044\u305f\u6587\u304cinput\u3068\u3057\u3066\u4e0e\u3048\u3089\u308c\u308b\u306e\u3067\u3001<br \/>\n&#8220;This is merely an example. Be careful. This is a new sentence.&#8221;<br \/>\n\u3068\u6b63\u3057\u304fCapitalize\u3057\u305f\u6587\u3092\u8fd4\u3057\u306a\u3055\u3044<\/p><\/blockquote>\n<p>\u30b7\u30f3\u30d7\u30eb\u306bCapitalize\u5fc5\u8981\u304b\u3069\u3046\u304b\u30d5\u30e9\u30b0\u6301\u3061\u306a\u304c\u3089\u8d70\u67fb\u3002<br \/>\n[cpp]<br \/>\nclass SentenceCapitalizerInator {<br \/>\npublic:<br \/>\n    string fixCaps(string paragraph) {<br \/>\n        string result = paragraph;<br \/>\n        bool needCapitalize = true;<br \/>\n        REP(i, SZ(result)) {<br \/>\n            if (needCapitalize &amp;&amp; result[i] != &#8216; &#8216;) {<br \/>\n                result[i] = result[i] + (&#8216;A&#8217; &#8211; &#8216;a&#8217;);<br \/>\n                needCapitalize = false;<br \/>\n            } else if (result[i] == &#8216;.&#8217;) {<br \/>\n                needCapitalize = true;<br \/>\n            }<br \/>\n        }<br \/>\n        return result;<br \/>\n    }<br \/>\n};<br \/>\n[\/cpp]<br \/>\n\u4eba\u306e\u89e3\u7b54\u898b\u3066toUpperCase\u306e\u5b58\u5728\u3092\u601d\u3044\u51fa\u3057\u305f\/\/\/<br \/>\n\u4e00\u5fdcPass\u3002<\/p>\n<p><strong>500<\/strong><\/p>\n<blockquote><p>\n{1, 3, 2} \u3068\u3044\u3046\u6570\u5217\u306f1 + 3 + 2 = 1 * 3 * 2 \u7a4d\u3068\u548c\u304c\u7b49\u3057\u304f\u306a\u3063\u3066\u3044\u3066\u3001\u3053\u3046\u3044\u3046\u306e\u3092Perfect Sequence\u3068\u547c\u3076\u3002<br \/>\n\u3042\u308b\u6570\u5217\u304c\u4e0e\u3048\u3089\u308c\u305f\u6642\u3001\u305d\u306e\u3046\u3061\u306e1\u3064\u3060\u3051\u6570\u5b57\u3092\u5909\u3048\u3066\u5b8c\u5168\u6570\u5217\u304c\u4f5c\u308c\u308b\u304b\u3069\u3046\u304b\u3092&#8221;Yes&#8221;\/&#8221;No&#8221;\u3067\u8fd4\u305b<br \/>\n\u4f8b\u3048\u3070\u3001{1, 3, 4} \u306f\u6700\u5f8c\u306e\u8981\u7d20\u30922\u306b\u5909\u3048\u308c\u3070Perfect Sequence\u306a\u306e\u3067Yes<br \/>\n{1, 4, 2, 4, 2, 4}\u306f\u3069\u306e\u8981\u7d20\u3092\u5909\u3048\u3066\u3082Perfect Sequence\u306b\u306a\u3089\u306a\u3044\u306e\u3067No<br \/>\n{1, 2, 3} \u306f\u3059\u3067\u306bPerfect Sequence\u306b\u306a\u3063\u3066\u3066\u3069\u308c\u304b\u3092\u5909\u3048\u308b\u3068\u5d29\u308c\u3066\u3057\u307e\u3046\u306e\u3067No\n<\/p><\/blockquote>\n<p>\u3084\u3063\u304b\u3044\u306a\u306e\u304c\u3001\u6570\u5217\u306e\u8981\u7d20\u6570\u306f50\u500b\u4ee5\u4e0b\u306a\u304c\u3089\u3001\u6570\u5217\u306e\u5404\u8981\u7d20\u304c0\u4ee5\u4e0a10^9\u4ee5\u4e0b\u306a\u3053\u3068\u3002<br \/>\n\u3075\u3064\u3046\u306b\u7a4d\u3092\u6c42\u3081\u3066\u308b\u3068\u3059\u3050\u30aa\u30fc\u30d0\u30fc\u30d5\u30ed\u30fc\u3059\u308b\u306e\u3067\u3001\u305d\u308c\u306b\u6c17\u3092\u3064\u3051\u306a\u304c\u3089\u63d0\u51fa\u3057\u305f\u3064\u3082\u308a\u306a\u304c\u3089\u3001<br \/>\n[cpp]<br \/>\n{1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000}<br \/>\n[\/cpp]<br \/>\n\u3063\u3066\u3044\u3046\u5178\u578b\u7684\u306a\u5883\u754c\u30c6\u30b9\u30c8\u3067\u6b63\u3057\u3044\u7b54\u3048\u3092\u8fd4\u305b\u305a\u3042\u3048\u306a\u304f\u6483\u6c88\u2026<br \/>\n[cpp]<br \/>\nclass PerfectSequences {<br \/>\npublic:<br \/>\n    string fixIt(vector &lt;int&gt; seq) {<\/p>\n<p>        if (SZ(seq) == 1) return &quot;Yes&quot;;<\/p>\n<p>        int sum = 0;<br \/>\n        REP(i, SZ(seq)) sum += seq[i];<\/p>\n<p>        int curPro = 1;<br \/>\n        REP(i, SZ(seq)) {<br \/>\n            curPro *= seq[i];<br \/>\n            if (curPro &gt; sum) break;<br \/>\n        }<br \/>\n        if (curPro == sum) return &quot;No&quot;;<\/p>\n<p>        REP(i, SZ(seq)) {<br \/>\n            int curSum = sum &#8211; seq[i];<br \/>\n            int product = 1;<br \/>\n            REP(j, SZ(seq)) {<br \/>\n                if (i != j) {<br \/>\n                    if (seq[j] == 0) {<br \/>\n                        if (curSum == 0)<br \/>\n                            return &quot;Yes&quot;;<br \/>\n                        else<br \/>\n                            goto LAST;<br \/>\n                    } else {<br \/>\n                        product *= seq[j];<br \/>\n                        if (product &gt; curSum) goto LAST;<br \/>\n                    }<br \/>\n                }<br \/>\n            }<br \/>\n            if (product == 1) {<br \/>\n                continue;<br \/>\n            } else {<br \/>\n                if (curSum % (product &#8211; 1) == 0) {<br \/>\n                    return &quot;Yes&quot;;<br \/>\n                }<br \/>\n            }<br \/>\nLAST:<br \/>\n            cerr &lt;&lt; curSum &lt;&lt; &quot;\/&quot; &lt;&lt; product &lt;&lt; endl;<br \/>\n        }<br \/>\n        return &quot;No&quot;;<br \/>\n    }<br \/>\n};<br \/>\n[\/cpp]<\/p>\n<p>\u30b3\u30fc\u30ca\u30fc\u30b1\u30fc\u30b9\u306e\u51e6\u7406\u3092\u3044\u304b\u306b\u304d\u3063\u3061\u308a\u66f8\u3051\u308b\u304b\u304c\u554f\u308f\u308c\u3066\u308b\u306e\u304b\u3001\u305d\u308c\u3068\u3082\u30b9\u30de\u30fc\u30c8\u306a\u89e3\u6cd5\u304c\u3042\u308b\u306e\u304b\u2026<br \/>\n\u5f8c\u3067\u8003\u3048\u3066\u307f\u3088\u30fc<\/p>\n<p><strong>900<\/strong><br \/>\n\u958b\u304b\u305a\u3002<\/p>\n<p>\u30b9\u30b3\u30a2\u306f243.29(250) + 0(500) + 0(900) &#8211; 25.00(\u30c1\u30e3\u30ec\u30f3\u30b8\u5931\u6557w) = 218.29<br \/>\nRating\u306f 835 -> 833<br \/>\nJ2\u751f\u6d3b\u306f\u307e\u3060\u307e\u3060\u7d9a\u304f\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3082\u306e\u3059\u3054\u304f\u4e45\u3057\u3076\u308a\u306eTopCoder. 250 \u3042\u308f\u3066\u3093\u307c\u3055\u3093\u304c &#8220;this is merely an example. be careful. this is a new sentence.&#8221;  &#8230; <a title=\"\u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2)\" class=\"read-more\" href=\"https:\/\/tech.fuqinho.net\/?p=48\" aria-label=\"\u8a73\u7d30\u306f\u3053\u3061\u3089 \u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2)\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[2],"tags":[5,13],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry","category-2","tag-cpp","tag-topcoder"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.2.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2) - Happy Coder<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tech.fuqinho.net\/?p=48\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2) - Happy Coder\" \/>\n<meta property=\"og:description\" content=\"\u3082\u306e\u3059\u3054\u304f\u4e45\u3057\u3076\u308a\u306eTopCoder. 250 \u3042\u308f\u3066\u3093\u307c\u3055\u3093\u304c &#8220;this is merely an example. be careful. this is a new sentence.&#8221; ... \u7d9a\u304d\u3092\u8aad\u3080\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tech.fuqinho.net\/?p=48\" \/>\n<meta property=\"og:site_name\" content=\"Happy Coder\" \/>\n<meta property=\"article:published_time\" content=\"2011-05-03T13:58:18+00:00\" \/>\n<meta name=\"author\" content=\"fuqinho\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"fuqinho\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"1\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/tech.fuqinho.net\/?p=48#article\",\"isPartOf\":{\"@id\":\"https:\/\/tech.fuqinho.net\/?p=48\"},\"author\":{\"name\":\"fuqinho\",\"@id\":\"https:\/\/tech.fuqinho.net\/#\/schema\/person\/3f5c2a20c9acba8360c501cb7038a4e7\"},\"headline\":\"\u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2)\",\"datePublished\":\"2011-05-03T13:58:18+00:00\",\"dateModified\":\"2011-05-03T13:58:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/tech.fuqinho.net\/?p=48\"},\"wordCount\":216,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/tech.fuqinho.net\/#\/schema\/person\/3f5c2a20c9acba8360c501cb7038a4e7\"},\"keywords\":[\"Cpp\",\"TopCoder\"],\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/tech.fuqinho.net\/?p=48#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tech.fuqinho.net\/?p=48\",\"url\":\"https:\/\/tech.fuqinho.net\/?p=48\",\"name\":\"\u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2) - Happy Coder\",\"isPartOf\":{\"@id\":\"https:\/\/tech.fuqinho.net\/#website\"},\"datePublished\":\"2011-05-03T13:58:18+00:00\",\"dateModified\":\"2011-05-03T13:58:18+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/tech.fuqinho.net\/?p=48#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tech.fuqinho.net\/?p=48\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tech.fuqinho.net\/?p=48#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u30db\u30fc\u30e0\",\"item\":\"https:\/\/tech.fuqinho.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tech.fuqinho.net\/#website\",\"url\":\"https:\/\/tech.fuqinho.net\/\",\"name\":\"Happy Coder\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/tech.fuqinho.net\/#\/schema\/person\/3f5c2a20c9acba8360c501cb7038a4e7\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tech.fuqinho.net\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"ja\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/tech.fuqinho.net\/#\/schema\/person\/3f5c2a20c9acba8360c501cb7038a4e7\",\"name\":\"fuqinho\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/tech.fuqinho.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/tech.fuqinho.net\/wp-content\/uploads\/2023\/02\/hatena-block_400x400.png\",\"contentUrl\":\"https:\/\/tech.fuqinho.net\/wp-content\/uploads\/2023\/02\/hatena-block_400x400.png\",\"width\":400,\"height\":400,\"caption\":\"fuqinho\"},\"logo\":{\"@id\":\"https:\/\/tech.fuqinho.net\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/tech.fuqinho.net\"],\"url\":\"https:\/\/tech.fuqinho.net\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2) - Happy Coder","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/tech.fuqinho.net\/?p=48","og_locale":"ja_JP","og_type":"article","og_title":"\u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2) - Happy Coder","og_description":"\u3082\u306e\u3059\u3054\u304f\u4e45\u3057\u3076\u308a\u306eTopCoder. 250 \u3042\u308f\u3066\u3093\u307c\u3055\u3093\u304c &#8220;this is merely an example. be careful. this is a new sentence.&#8221; ... \u7d9a\u304d\u3092\u8aad\u3080","og_url":"https:\/\/tech.fuqinho.net\/?p=48","og_site_name":"Happy Coder","article_published_time":"2011-05-03T13:58:18+00:00","author":"fuqinho","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"fuqinho","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"1\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/tech.fuqinho.net\/?p=48#article","isPartOf":{"@id":"https:\/\/tech.fuqinho.net\/?p=48"},"author":{"name":"fuqinho","@id":"https:\/\/tech.fuqinho.net\/#\/schema\/person\/3f5c2a20c9acba8360c501cb7038a4e7"},"headline":"\u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2)","datePublished":"2011-05-03T13:58:18+00:00","dateModified":"2011-05-03T13:58:18+00:00","mainEntityOfPage":{"@id":"https:\/\/tech.fuqinho.net\/?p=48"},"wordCount":216,"commentCount":0,"publisher":{"@id":"https:\/\/tech.fuqinho.net\/#\/schema\/person\/3f5c2a20c9acba8360c501cb7038a4e7"},"keywords":["Cpp","TopCoder"],"inLanguage":"ja","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/tech.fuqinho.net\/?p=48#respond"]}]},{"@type":"WebPage","@id":"https:\/\/tech.fuqinho.net\/?p=48","url":"https:\/\/tech.fuqinho.net\/?p=48","name":"\u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2) - Happy Coder","isPartOf":{"@id":"https:\/\/tech.fuqinho.net\/#website"},"datePublished":"2011-05-03T13:58:18+00:00","dateModified":"2011-05-03T13:58:18+00:00","breadcrumb":{"@id":"https:\/\/tech.fuqinho.net\/?p=48#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tech.fuqinho.net\/?p=48"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/tech.fuqinho.net\/?p=48#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u30db\u30fc\u30e0","item":"https:\/\/tech.fuqinho.net\/"},{"@type":"ListItem","position":2,"name":"\u4e45\u3057\u3076\u308a\u306eTopCoder (SRM 505 div2)"}]},{"@type":"WebSite","@id":"https:\/\/tech.fuqinho.net\/#website","url":"https:\/\/tech.fuqinho.net\/","name":"Happy Coder","description":"","publisher":{"@id":"https:\/\/tech.fuqinho.net\/#\/schema\/person\/3f5c2a20c9acba8360c501cb7038a4e7"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tech.fuqinho.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"ja"},{"@type":["Person","Organization"],"@id":"https:\/\/tech.fuqinho.net\/#\/schema\/person\/3f5c2a20c9acba8360c501cb7038a4e7","name":"fuqinho","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/tech.fuqinho.net\/#\/schema\/person\/image\/","url":"https:\/\/tech.fuqinho.net\/wp-content\/uploads\/2023\/02\/hatena-block_400x400.png","contentUrl":"https:\/\/tech.fuqinho.net\/wp-content\/uploads\/2023\/02\/hatena-block_400x400.png","width":400,"height":400,"caption":"fuqinho"},"logo":{"@id":"https:\/\/tech.fuqinho.net\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/tech.fuqinho.net"],"url":"https:\/\/tech.fuqinho.net\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/tech.fuqinho.net\/index.php?rest_route=\/wp\/v2\/posts\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech.fuqinho.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.fuqinho.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.fuqinho.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.fuqinho.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=48"}],"version-history":[{"count":0,"href":"https:\/\/tech.fuqinho.net\/index.php?rest_route=\/wp\/v2\/posts\/48\/revisions"}],"wp:attachment":[{"href":"https:\/\/tech.fuqinho.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.fuqinho.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.fuqinho.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}