{"id":1526,"date":"2023-06-27T13:54:14","date_gmt":"2023-06-27T05:54:14","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=1526"},"modified":"2023-06-27T13:54:14","modified_gmt":"2023-06-27T05:54:14","slug":"%e8%ae%a1%e7%ae%97%e4%ba%8c%e8%bf%9b%e5%88%b6%e8%a1%a8%e8%be%be%e5%bc%8f%e4%b8%ad%e6%95%b0%e5%ad%97%e4%bd%8d%e6%95%b0%e4%b8%ba-1-%e7%9a%84%e4%b8%aa%e6%95%b0","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/%e7%ae%97%e6%b3%95\/%e8%ae%a1%e7%ae%97%e4%ba%8c%e8%bf%9b%e5%88%b6%e8%a1%a8%e8%be%be%e5%bc%8f%e4%b8%ad%e6%95%b0%e5%ad%97%e4%bd%8d%e6%95%b0%e4%b8%ba-1-%e7%9a%84%e4%b8%aa%e6%95%b0\/","title":{"rendered":"\u8ba1\u7b97\u4e8c\u8fdb\u5236\u8868\u8fbe\u5f0f\u4e2d\u6570\u5b57\u4f4d\u6570\u4e3a \u20181\u2019 \u7684\u4e2a\u6570"},"content":{"rendered":"<div class='wxsyncmain'>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;font-weight: bold;font-size: 1.3em;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;text-align: left;white-space: normal;text-size-adjust: auto;border-bottom: 2px solid rgb(239, 112, 96);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"margin-right: 3px;padding: 3px 10px 1px;outline: 0px;max-width: 100%;display: inline-block;background-color: rgb(239, 112, 96);color: rgb(255, 255, 255);border-top-right-radius: 3px;border-top-left-radius: 3px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u9898\u76ee<\/span><span style=\"outline: 0px;max-width: 100%;display: inline-block;vertical-align: bottom;border-bottom: 36px solid rgb(239, 235, 233);border-right: 20px solid transparent;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><\/span><\/h2>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;display: flex;flex-direction: column;justify-content: center;align-items: center;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/figure>\n<blockquote class=\"js_blockquote_wrap\" data-type=\"2\" data-url=\"\" data-author-name=\"\" data-content-utf8-length=\"62\" data-source-title=\"https:\/\/leetcode.cn\/problems\/number-of-1-bits\/description\/\">\n<section class=\"js_blockquote_digest\">\n<section>\u7f16\u5199\u4e00\u4e2a\u51fd\u6570\uff0c\u8f93\u5165\u662f\u4e00\u4e2a\u65e0\u7b26\u53f7\u6574\u6570\uff08\u4ee5\u4e8c\u8fdb\u5236\u4e32\u7684\u5f62\u5f0f\uff09\uff0c\u8fd4\u56de\u5176\u4e8c\u8fdb\u5236\u8868\u8fbe\u5f0f\u4e2d\u6570\u5b57\u4f4d\u6570\u4e3a '1' \u7684\u4e2a\u6570\uff08\u4e5f\u88ab\u79f0\u4e3a\u6c49\u660e\u91cd\u91cf\uff09\u3002<\/section>\n<\/section>\n<section class=\"blockquote_info js_blockquote_source\" data-json=\"%7B%22type%22%3A%22out%22%2C%22source%22%3A%22url%22%2C%22digest%22%3A%22%22%2C%22digestLen%22%3A62%2C%22text%22%3A%22%E7%BC%96%E5%86%99%E4%B8%80%E4%B8%AA%E5%87%BD%E6%95%B0%EF%BC%8C%E8%BE%93%E5%85%A5%E6%98%AF%E4%B8%80%E4%B8%AA%E6%97%A0%E7%AC%A6%E5%8F%B7%E6%95%B4%E6%95%B0%EF%BC%88%E4%BB%A5%E4%BA%8C%E8%BF%9B%E5%88%B6%E4%B8%B2%E7%9A%84%E5%BD%A2%E5%BC%8F%EF%BC%89%EF%BC%8C%E8%BF%94%E5%9B%9E%E5%85%B6%E4%BA%8C%E8%BF%9B%E5%88%B6%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%B8%AD%E6%95%B0%E5%AD%97%E4%BD%8D%E6%95%B0%E4%B8%BA%20&#39;1&#39;%20%E7%9A%84%E4%B8%AA%E6%95%B0%EF%BC%88%E4%B9%9F%E8%A2%AB%E7%A7%B0%E4%B8%BA%E6%B1%89%E6%98%8E%E9%87%8D%E9%87%8F%EF%BC%89%E3%80%82%22%2C%22article%22%3A%7B%7D%2C%22hasReportOverSize%22%3Afalse%2C%22editorReportData%22%3A%5B%7B%22id%22%3A%22122333%22%2C%22key%22%3A%2276%22%2C%22len%22%3A1%7D%5D%2C%22from%22%3A%22https%3A%2F%2Fleetcode.cn%2Fproblems%2Fnumber-of-1-bits%2Fdescription%2F%22%7D\"><span class=\"blockquote_other\">https:\/\/leetcode.cn\/problems\/number-of-1-bits\/description\/<\/span><\/section>\n<p><span style=\"display: none;line-height: 0px;\">\u200d<\/span><\/p><\/blockquote>\n<p><br  \/><\/p>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 1.3em;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;text-align: left;white-space: normal;text-size-adjust: auto;border-bottom: 2px solid rgb(239, 112, 96);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"margin-right: 3px;padding: 3px 10px 1px;outline: 0px;max-width: 100%;display: inline-block;background-color: rgb(239, 112, 96);color: rgb(255, 255, 255);border-top-right-radius: 3px;border-top-left-radius: 3px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u89e3\u6cd5\u4e00\uff1a\u53f3\u79fb\u7edf\u8ba1<\/span><span style=\"outline: 0px;max-width: 100%;display: inline-block;vertical-align: bottom;border-bottom: 36px solid rgb(239, 235, 233);border-right: 20px solid transparent;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><\/span><\/h2>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;display: flex;flex-direction: column;justify-content: center;align-items: center;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/figure>\n<h3 style=\"box-sizing: border-box;outline: 0px;margin-top: 8px;margin-bottom: 16px;font-weight: 600;font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;font-size: 20px;color: rgb(79, 79, 79);line-height: 28px;overflow-wrap: break-word;font-variant-ligatures: no-common-ligatures;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\"><span style=\"font-size: 17px;\">\u89e3\u9898\u601d\u8def<\/span><\/h3>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u53f3\u79fb\u7edf\u8ba1\uff0c\u5224\u65ad\u6700\u540e\u4e00\u4f4d\u662f\u5426\u4e3a 1\u3002<\/p>\n<ol class=\"list-paddingleft-1\" style=\"list-style-type: decimal;\">\n<li>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u53ea\u8981 n != 0\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u77e5\u9053 n \u7684\u4e8c\u8fdb\u5236\u8868\u793a\u5f53\u4e2d\u80af\u5b9a\u5305\u542b\u6709 1\uff0c\u4e0d\u7ba1\u5b83\u5728\u54ea\u4e2a\u4f4d\u7f6e\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u53ea\u8981 n &amp; 1 = 1\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u77e5\u9053 n \u7684\u6700\u540e\u4e00\u4f4d\u80af\u5b9a\u662f1\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u90a3\u4e48\u6839\u636e\u524d\u4e24\u4e2a\u6761\u4ef6\uff0c\u6211\u4eec\u53ef\u4ee5\u628a n \u4e0d\u65ad\u7684\u5411\u53f3\u79fb 1 \u4f4d\uff0c\u9ad8\u4f4d\u88650, \u7136\u540e\u4e0d\u65ad\u7d2f\u52a0\u8bb0\u5f55\u6700\u540e\u4e00\u4f4d\u662f 1 \u7684\u6b21\u6570\uff0c\u76f4\u5230\u79fb\u52a8\u5230 n = 0 \u7ed3\u675f\u3002<\/p>\n<\/li>\n<\/ol>\n<p style=\"box-sizing: border-box;outline: 0px;margin-top: 8px;margin-bottom: 16px;font-weight: 600;font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;font-size: 20px;color: rgb(79, 79, 79);line-height: 28px;overflow-wrap: break-word;font-variant-ligatures: no-common-ligatures;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\"><span style=\"font-size: 17px;\">\u4ee3\u7801\u5b9e\u73b0<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"cs\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__keyword\">public<\/span> <span class=\"code-snippet__keyword\">class<\/span> <span class=\"code-snippet__title\">Solution<\/span> {<\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__function\"><span class=\"code-snippet__keyword\">public<\/span> <span class=\"code-snippet__keyword\">int<\/span> <span class=\"code-snippet__title\">hammingWeight<\/span>(<span class=\"code-snippet__params\"><span class=\"code-snippet__keyword\">int<\/span> n<\/span>)<\/span> {<\/span><\/code><code><span class=\"code-snippet_outer\">        <span class=\"code-snippet__keyword\">int<\/span> cnt = <span class=\"code-snippet__number\">0<\/span>;<\/span><\/code><code><span class=\"code-snippet_outer\">        <span class=\"code-snippet__keyword\">while<\/span>(n != <span class=\"code-snippet__number\">0<\/span>){<\/span><\/code><code><span class=\"code-snippet_outer\">            <span class=\"code-snippet__keyword\">if<\/span>((n &amp; <span class=\"code-snippet__number\">1<\/span>) == <span class=\"code-snippet__number\">1<\/span>){<\/span><\/code><code><span class=\"code-snippet_outer\">                cnt++;<\/span><\/code><code><span class=\"code-snippet_outer\">            }<\/span><\/code><code><span class=\"code-snippet_outer\">            <span class=\"code-snippet__comment\">\/\/ \u903b\u8f91\u53f3\u79fb\u52a8\uff0c\u9ad8\u4f4d\u88650\uff1b<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">            <span class=\"code-snippet__comment\">\/\/ \u8fd9\u91cc\u4e0d\u80fd\u4f7f\u7528\u7b97\u672f\u53f3\u79fb\uff0c\u56e0\u4e3a\u7b97\u672f\u53f3\u79fb\u4f1a\u5728\u9ad8\u4f4d\u8865\u7b26\u53f7\u4f4d\uff0c<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">            <span class=\"code-snippet__comment\">\/\/ \u5982\u679c\u662f\u8d1f\u6570\uff0c\u90a3\u4e48\u9ad8\u4f4d\u4f1a\u88651\uff0c\u8fd9\u6837\u4f1a\u5bfc\u81f4while\u5faa\u73af\u4e00\u76f4\u51fa\u4e0d\u53bb\u3002<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">            n = n &gt;&gt;&gt; <span class=\"code-snippet__number\">1<\/span>;<\/span><\/code><code><span class=\"code-snippet_outer\">        }<\/span><\/code><code><span class=\"code-snippet_outer\">        <span class=\"code-snippet__keyword\">return<\/span> cnt;<\/span><\/code><code><span class=\"code-snippet_outer\">    }<\/span><\/code><code><span class=\"code-snippet_outer\">}<\/span><\/code><\/pre>\n<\/section>\n<p><br  \/><\/p>\n<p><span style=\"background-color: rgb(255, 255, 255);color: rgb(79, 79, 79);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;font-variant-ligatures: no-common-ligatures;font-weight: 600;text-align: start;\">\u590d\u6742\u5ea6\u5206\u6790<\/span><\/p>\n<p><strong><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;caret-color: rgb(0, 0, 0);\">\u65f6\u95f4\u590d\u6742\u5ea6 <\/span><em><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;caret-color: rgb(0, 0, 0);\">O(logN)<\/span><\/em><\/strong><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;caret-color: rgb(0, 0, 0);\">\uff1a<\/span><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;caret-color: rgb(0, 0, 0);\">\u65f6\u95f4\u590d\u6742\u5ea6\u4e3awhile\u5faa\u73af\u7684\u6b21\u6570\uff0c\u53d6\u51b3\u4e8e n \u7684\u4e8c\u8fdb\u5236\u8868\u793a\u4e2d\u6700\u9ad8\u4f4d\u7684 1 \u5728\u54ea\u4e2a\u4f4d\u7f6e\uff0c\u5373\u4ee52\u4e3a\u5e95\u7684log(n)\u5411\u4e0b\u53d6\u6574 + 1\uff0c\u6700\u574f\u7684\u60c5\u51b5\u4e0b\u5c31\u662f32\u6b21\u3002<\/span><\/p>\n<p><span style=\"font-size: 16px;\"><strong>\u7a7a\u95f4\u590d\u6742\u5ea6 <em>O(1)<\/em><\/strong>\uff1a<\/span><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;caret-color: rgb(0, 0, 0);\">\u53ea\u5f00\u4e86\u4e00\u4e2a\u53d8\u91cfcnt\u7528\u4e8e\u5b58\u653e\u7ed3\u679c\uff0c\u7a7a\u95f4\u590d\u6742\u5ea6\u4e3a1\u3002<\/span><\/p>\n<p><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;caret-color: rgb(0, 0, 0);\"><br  \/><\/span><\/p>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;font-weight: bold;font-size: 1.3em;white-space: normal;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;text-align: left;text-size-adjust: auto;border-bottom: 2px solid rgb(239, 112, 96);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"margin-right: 3px;padding: 3px 10px 1px;outline: 0px;max-width: 100%;display: inline-block;background-color: rgb(239, 112, 96);color: rgb(255, 255, 255);border-top-right-radius: 3px;border-top-left-radius: 3px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u89e3\u6cd5\u4e8c\uff1a\u6e05\u9664\u6700\u4f4e\u4f4d<\/span><span style=\"outline: 0px;max-width: 100%;display: inline-block;vertical-align: bottom;border-bottom: 36px solid rgb(239, 235, 233);border-right: 20px solid transparent;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><\/span><\/h2>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;white-space: normal;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;text-size-adjust: auto;display: flex;flex-direction: column;justify-content: center;align-items: center;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/figure>\n<h3 style=\"margin-top: 8px;margin-bottom: 16px;font-weight: 600;font-size: 20px;white-space: normal;box-sizing: border-box;outline: 0px;font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;color: rgb(79, 79, 79);line-height: 28px;overflow-wrap: break-word;font-variant-ligatures: no-common-ligatures;text-align: start;background-color: rgb(255, 255, 255);\"><span style=\"font-size: 17px;\">\u89e3\u9898\u601d\u8def<\/span><\/h3>\n<p style=\"box-sizing: border-box;outline: 0px;margin-bottom: 16px;font-size: 16px;color: rgb(77, 77, 77);line-height: 26px;overflow: auto hidden;overflow-wrap: break-word;font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif;font-variant-ligatures: no-common-ligatures;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u4f7f\u7528\u6700\u4f4e\u4f4d\u7684\u601d\u8def\uff0cn = n &amp; (n - 1) \u8868\u793a\u5220\u6389 n \u7684\u6700\u4f4e\u4f4d\u3002<\/p>\n<ol style=\"list-style-type: decimal;\" class=\"list-paddingleft-1\">\n<li style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 1.6em;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u53ea\u8981 n != 0, \u8868\u793a n \u7684\u4e8c\u8fdb\u5236\u8868\u793a\u4e2d\u5305\u542b\u6709 1\uff0c\u8ba1\u6570\u52a0\u4e00\u3002<\/p>\n<\/li>\n<li style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 1.6em;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u5220\u6389 n \u7684\u6700\u4f4e\u4f4d\uff0c\u5224\u65ad\u662f\u5426\u8fd8\u6ee1\u8db3 n != 0\uff0c\u6ee1\u8db3\u5219\u8ba1\u6570\u52a0\u4e00\u5e76\u7ee7\u7eed\u5220\u6389\u6700\u4f4e\u4f4d\uff1b\u4e0d\u6ee1\u8db3\u5219\u7ed3\u675f\u3002<\/p>\n<\/li>\n<\/ol>\n<p style=\"margin-top: 8px;margin-bottom: 16px;font-weight: 600;font-size: 20px;white-space: normal;box-sizing: border-box;outline: 0px;font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;color: rgb(79, 79, 79);line-height: 28px;overflow-wrap: break-word;font-variant-ligatures: no-common-ligatures;text-align: start;background-color: rgb(255, 255, 255);\"><span style=\"font-size: 17px;\">\u4ee3\u7801\u5b9e\u73b0<\/span><br  \/><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"cs\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__keyword\">public<\/span> <span class=\"code-snippet__keyword\">class<\/span> <span class=\"code-snippet__title\">Solution<\/span> {<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__function\"><span class=\"code-snippet__keyword\">public<\/span> <span class=\"code-snippet__keyword\">int<\/span> <span class=\"code-snippet__title\">hammingWeight<\/span>(<span class=\"code-snippet__params\"><span class=\"code-snippet__keyword\">int<\/span> n<\/span>)<\/span> {<\/span><\/code><code><span class=\"code-snippet_outer\">        <span class=\"code-snippet__keyword\">int<\/span> cnt = <span class=\"code-snippet__number\">0<\/span>;<\/span><\/code><code><span class=\"code-snippet_outer\">        <span class=\"code-snippet__keyword\">while<\/span>(n != <span class=\"code-snippet__number\">0<\/span>){<\/span><\/code><code><span class=\"code-snippet_outer\">            cnt++;<\/span><\/code><code><span class=\"code-snippet_outer\">            n = n &amp; (n - <span class=\"code-snippet__number\">1<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">        }<\/span><\/code><code><span class=\"code-snippet_outer\">        <\/span><\/code><code><span class=\"code-snippet_outer\">        <span class=\"code-snippet__keyword\">return<\/span> cnt;<\/span><\/code><code><span class=\"code-snippet_outer\">    }<\/span><\/code><code><span class=\"code-snippet_outer\">}<\/span><\/code><\/pre>\n<\/section>\n<p style=\"margin-top: 8px;margin-bottom: 16px;font-weight: 600;font-size: 20px;white-space: normal;box-sizing: border-box;outline: 0px;font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;color: rgb(79, 79, 79);line-height: 28px;overflow-wrap: break-word;font-variant-ligatures: no-common-ligatures;text-align: start;background-color: rgb(255, 255, 255);\"><span style=\"font-size: 17px;\"><br  \/><\/span><\/p>\n<p style=\"margin-top: 8px;margin-bottom: 16px;font-weight: 600;font-size: 20px;white-space: normal;box-sizing: border-box;outline: 0px;font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;color: rgb(79, 79, 79);line-height: 28px;overflow-wrap: break-word;font-variant-ligatures: no-common-ligatures;text-align: start;background-color: rgb(255, 255, 255);\"><span style=\"font-size: 17px;\">\u590d\u6742\u5ea6\u5206\u6790<\/span><span style=\"font-size: 17px;\"><\/span><\/p>\n<section>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;display: flex;flex-direction: column;justify-content: center;align-items: center;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\n<p><strong><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;caret-color: rgb(0, 0, 0);\">\u65f6\u95f4\u590d\u6742\u5ea6 O(M)<\/span><\/strong><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;caret-color: rgb(0, 0, 0);\">\uff1a\u65f6\u95f4\u590d\u6742\u5ea6M\u4e3a\u4e8c\u8fdb\u5236\u8868\u793a\u4e2d 1 \u7684\u4e2a\u6570\uff0cM &lt;= log(n) + 1\u3002\u5f53\u6700\u9ad8\u4f4d\u662f1\uff0c\u5176\u4ed6\u4f4d\u90fd\u662f0\u7684\u65f6\u5019\uff0c\u89e3\u6cd5\u4e00\u9700\u898132\u6b21\uff0c\u89e3\u6cd5\u4e8c\u53ea\u9700\u89811\u6b21\u3002<\/span><\/p>\n<\/figure>\n<\/section>\n<p><strong><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;caret-color: rgb(0, 0, 0);\">\u7a7a\u95f4\u590d\u6742\u5ea6 O(1)<\/span><\/strong><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;caret-color: rgb(0, 0, 0);\">\uff1a\u53ea\u5f00\u4e86\u4e00\u4e2a\u53d8\u91cfcnt\u7528\u4e8e\u5b58\u653e\u7ed3\u679c\uff0c\u7a7a\u95f4\u590d\u6742\u5ea6\u4e3a1\u3002<\/span><\/p>\n<p><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;caret-color: rgb(0, 0, 0);\"><br  \/><\/span><\/p>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;font-weight: bold;font-size: 1.3em;white-space: normal;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;text-align: left;text-size-adjust: auto;border-bottom: 2px solid rgb(239, 112, 96);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"margin-right: 3px;padding: 3px 10px 1px;outline: 0px;max-width: 100%;display: inline-block;background-color: rgb(239, 112, 96);color: rgb(255, 255, 255);border-top-right-radius: 3px;border-top-left-radius: 3px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u89e3<span style=\"color: rgb(255, 255, 255);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 22.1px;font-weight: 700;text-align: left;caret-color: rgb(0, 0, 0);background-color: rgb(239, 112, 96);\">\u6cd5\u4e09\uff1a<\/span><span style=\"color: rgb(255, 255, 255);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 22.1px;font-weight: 700;text-align: left;caret-color: rgb(0, 0, 0);background-color: rgb(239, 112, 96);\">\u5206\u6cbb<\/span><\/span><span style=\"outline: 0px;max-width: 100%;display: inline-block;vertical-align: bottom;border-bottom: 36px solid rgb(239, 235, 233);border-right: 20px solid transparent;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><\/span><\/h2>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;white-space: normal;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;text-size-adjust: auto;display: flex;flex-direction: column;justify-content: center;align-items: center;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/figure>\n<p style=\"margin-top: 8px;margin-bottom: 16px;font-weight: 600;font-size: 20px;white-space: normal;box-sizing: border-box;outline: 0px;font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;color: rgb(79, 79, 79);line-height: 28px;overflow-wrap: break-word;font-variant-ligatures: no-common-ligatures;text-align: start;background-color: rgb(255, 255, 255);\"><span style=\"font-size: 17px;\">\u89e3\u9898\u601d\u8def<\/span><\/p>\n<p style=\"box-sizing: border-box;outline: 0px;margin-bottom: 16px;font-size: 16px;color: rgb(77, 77, 77);line-height: 26px;overflow: auto hidden;overflow-wrap: break-word;font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif;font-variant-ligatures: no-common-ligatures;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u5229\u7528\u5206\u6cbb\u7684\u601d\u60f3\uff0c\u5c06\u6bcf\u4e2a\u4f4d\u7f6e\u76841\u52a0\u8d77\u6765\u5373\u53ef\uff0c\u4ee5181=1011 0101\u4e3a\u4f8b\uff1a<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">1. \u4e24\u4e24\u4e00\u7ec4\u76f8\u52a0\uff0c\u5c068\u4f4d\u4e8c\u8fdb\u5236\u4f1a\u5206\u4e3a4\u7ec4\uff08\u5982\u679c\u662f32\u4f4d\uff0c\u90a3\u4e48\u5c31\u4f1a\u5206\u621016\u7ec4\uff09\u3002\u76f8\u52a0\u540e\u4e8c\u8fdb\u5236\u8868\u8fbe\u4e3a 01_10_01_01\uff0c\u4ee3\u8868\u7684\u662f4\u7ec4\u7ed3\u679c\uff1a1 + 2 + 1 + 1 = 5\u3002<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">2. \u5c06\u7b2c\u4e00\u6b65\u5f97\u5230\u76844\u7ec4\u7ed3\u679c\u518d\u8fdb\u884c\u4e24\u4e24\u4e00\u7ec4\u76f8\u52a0\uff0c\u7ed3\u679c\u4e3a0011_0010, \u4ee3\u8868 3 + 2 = 5\u3002<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">3. \u5c06\u7b2c\u4e8c\u6b65\u5f97\u5230\u76842\u7ec4\u7ed3\u679c\u5408\u5e76\u76f8\u52a0\uff0c\u7ed3\u679c\u4e3a00000101=5\u3002<\/p>\n<p style=\"box-sizing: border-box;outline: 0px;margin-bottom: 16px;font-size: 16px;color: rgb(77, 77, 77);line-height: 26px;overflow: auto hidden;overflow-wrap: break-word;font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif;font-variant-ligatures: no-common-ligatures;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\"><strong>\u6ce8\u610f\uff1a<\/strong>\u76f4\u5230\u6700\u540e\u4e00\u6b65\u7684\u65f6\u5019\uff0c\u6240\u6709\u7684\u4e8c\u8fdb\u5236\u4f4d\u90fd\u5408\u5e76\u4e3a\u4e00\u7ec4\u7684\u65f6\u5019\uff0c\u5176\u7ed3\u679c\u624d\u662f\u4e00\u4e2a\u771f\u6b63\u7684\u6570\u503c\uff0c\u524d\u9762\u6240\u6709\u6b65\u9aa4\u4e2d\u7684\u7ed3\u679c\u53ea\u5728\u5206\u7ec4\u4e2d\u662f\u6709\u6548\u6570\u503c\u300232\u4f4d\u8ba1\u6570\u540c\u7406\u3002<\/p>\n<p><img decoding=\"async\" class=\"rich_pages wxw-img js_insertlocalimg lazyload\" data-ratio=\"0.6597145993413831\" data-s=\"300,640\"  data-type=\"png\" data-w=\"911\" style=\"text-align: center;white-space: normal;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043513167.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img js_insertlocalimg\" data-ratio=\"0.6597145993413831\" data-s=\"300,640\"  data-type=\"png\" data-w=\"911\" style=\"text-align: center;white-space: normal;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043513167.png\"><\/noscript><\/p>\n<p><br  \/><\/p>\n<p style=\"margin-top: 8px;margin-bottom: 16px;font-weight: 600;font-size: 20px;white-space: normal;box-sizing: border-box;outline: 0px;font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;color: rgb(79, 79, 79);line-height: 28px;overflow-wrap: break-word;font-variant-ligatures: no-common-ligatures;text-align: start;background-color: rgb(255, 255, 255);\"><span style=\"font-size: 17px;\">\u7b97\u6cd5\u56fe\u89e3\uff1a<\/span><\/p>\n<p style=\"box-sizing: border-box;outline: 0px;margin-bottom: 16px;font-size: 16px;color: rgb(77, 77, 77);line-height: 26px;overflow: auto hidden;overflow-wrap: break-word;font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif;font-variant-ligatures: no-common-ligatures;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u601d\u8def\u6709\u4e86\uff0c\u90a3\u4e48\u63a5\u4e0b\u6765\u5206\u6790\u5982\u4f55\u8ba9\u4e24\u4e24\u4e00\u7ec4\u76f8\u52a0\u5462\uff1f<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">1. \u6211\u4eec\u53ef\u4ee5\u65b0\u5f00\u4e00\u4e2a\u6570\uff0c\u4f7f\u5176\u4e8c\u8fdb\u5236\u8868\u8fbe\u4e3a\u539f\u6570\u503c\u7684\u4e8c\u8fdb\u5236\u5411\u540e\u79fb\u52a8\u4e00\u4f4d\uff0c\u9996\u4f4d\u88650\uff0c\u8fd9\u6837\u5c31\u521a\u597d\u8ba9\u5206\u5728\u540c\u4e00\u7ec4\u7684\u4e24\u4e2a\u4f4d\u7f6e\u5bf9\u5176\u3002<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">2. \u5bf9\u9f50\u540e\u6211\u4eec\u9700\u8981\u4e24\u4e2a\u6570\u76f8\u52a0\uff0c\u6211\u4eec\u9700\u8981\u5c06\u539f\u6570\u503c\u4e2d\u7eff\u8272\u90e8\u5206\u548c\u65b0\u6570\u503c\u7684\u84dd\u8272\u90e8\u5206\u6e05\u7a7a\uff08\u91cd\u590d\u5197\u4f59\u6570\u636e\uff09\uff0c\u6e05\u7a7a\u65b9\u5f0f\u4e3a &amp;01010101, 16\u8fdb\u5236\u8868\u8fbe\u4e3a &amp;0x55\u3002<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">3. \u76f8\u52a0\u7ed3\u679c\u4e3a01_10_01_01\uff0c\u4e0e\u4e0a\u8ff0\u89e3\u9898\u601d\u8def\u5f97\u5230\u4e00\u81f4\u7684\u7ed3\u679c\u3002<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img js_insertlocalimg lazyload\" data-ratio=\"1.0831600831600832\" data-s=\"300,640\"  data-type=\"png\" data-w=\"481\" style=\"\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043514642.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img js_insertlocalimg\" data-ratio=\"1.0831600831600832\" data-s=\"300,640\"  data-type=\"png\" data-w=\"481\" style=\"\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043514642.png\"><\/noscript><\/p>\n<p><br  \/><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">4. \u5c06\u7b2c\u4e09\u6b65\u5f97\u5230\u7684\u7ed3\u679c\u518d\u5206\u7ec4\u76f8\u52a0\uff0c\u903b\u8f91\u540c\u4e0a\u3002\u4f46\u662f\u8fd9\u4e2a\u65f6\u5019\u6bcf\u4e2a\u5206\u7ec4\u4e2d\u67092\u4e2a\u4f4d\u7f6e\uff0c\u6240\u6709\u5220\u9664\u5197\u4f59\u6570\u636e\u7684\u65f6\u5019\u9700\u8981 &amp;00110011 = &amp;0x33\u3002<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-galleryid=\"\" data-ratio=\"0.872255489021956\" data-s=\"300,640\"  data-type=\"png\" data-w=\"501\" style=\"\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043515518.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-galleryid=\"\" data-ratio=\"0.872255489021956\" data-s=\"300,640\"  data-type=\"png\" data-w=\"501\" style=\"\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043515518.png\"><\/noscript><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">5. \u5faa\u73af\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u76f4\u5230\u6240\u6709\u4e8c\u8fdb\u5236\u4f4d\u90fd\u88ab\u5206\u5230\u540c\u4e00\u7ec4\u4e3a\u7b54\u6848\u3002<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<p style=\"margin-top: 8px;margin-bottom: 16px;font-weight: 600;font-size: 20px;white-space: normal;box-sizing: border-box;outline: 0px;font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;color: rgb(79, 79, 79);line-height: 28px;overflow-wrap: break-word;font-variant-ligatures: no-common-ligatures;text-align: start;background-color: rgb(255, 255, 255);\"><span style=\"font-size: 17px;\">\u4ee3\u7801\u5b9e\u73b0<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"ruby\"><code><span class=\"code-snippet_outer\">public <span class=\"code-snippet__class\"><span class=\"code-snippet__keyword\">class<\/span> <span class=\"code-snippet__title\">Solution<\/span> {<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">   public int hammingWeight(int n) {<\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__regexp\">\/\/<\/span> \u6bcf\u7ec4<span class=\"code-snippet__number\">1<\/span>\u4e2a\u4f4d\u7f6e\uff0c\u53f3\u79fb<span class=\"code-snippet__number\">1<\/span>\u4f4d\u5bf9\u9f50\u5e76\u5220\u9664\u5197\u4f59\u6570\u636e\uff08&amp;<span class=\"code-snippet__number\">01010101<\/span>\uff09\u3002<\/span><\/code><code><span class=\"code-snippet_outer\">        n = (n &amp; <span class=\"code-snippet__number\">0x55555555<\/span>) + ((n <span class=\"code-snippet__meta\">&gt;&gt;&gt; <\/span><span class=\"code-snippet__number\">1<\/span>) &amp; <span class=\"code-snippet__number\">0x55555555<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">        <span class=\"code-snippet__regexp\">\/\/<\/span> \u6bcf\u7ec4<span class=\"code-snippet__number\">2<\/span>\u4e2a\u4f4d\u7f6e\uff0c\u53f3\u79fb<span class=\"code-snippet__number\">2<\/span>\u4f4d\u5bf9\u9f50\u5e76\u5220\u9664\u5197\u4f59\u6570\u636e\uff08&amp;<span class=\"code-snippet__number\">00110011<\/span>\uff09\u3002<\/span><\/code><code><span class=\"code-snippet_outer\">        n = (n &amp; <span class=\"code-snippet__number\">0x33333333<\/span>) + ((n <span class=\"code-snippet__meta\">&gt;&gt;&gt; <\/span><span class=\"code-snippet__number\">2<\/span>) &amp; <span class=\"code-snippet__number\">0x33333333<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">        <span class=\"code-snippet__regexp\">\/\/<\/span> \u6bcf\u7ec4<span class=\"code-snippet__number\">4<\/span>\u4e2a\u4f4d\u7f6e\uff0c\u53f3\u79fb<span class=\"code-snippet__number\">4<\/span>\u4f4d\u5bf9\u9f50\u5e76\u5220\u9664\u5197\u4f59\u6570\u636e\uff08&amp;<span class=\"code-snippet__number\">00001111<\/span>\uff09\u3002<\/span><\/code><code><span class=\"code-snippet_outer\">        n = (n &amp; <span class=\"code-snippet__number\">0x0f0f0f0f<\/span>) + ((n <span class=\"code-snippet__meta\">&gt;&gt;&gt; <\/span><span class=\"code-snippet__number\">4<\/span>) &amp; <span class=\"code-snippet__number\">0x0f0f0f0f<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">        <span class=\"code-snippet__regexp\">\/\/<\/span> \u6bcf\u7ec4<span class=\"code-snippet__number\">8<\/span>\u4e2a\u4f4d\u7f6e\uff0c\u53f3\u79fb<span class=\"code-snippet__number\">8<\/span>\u4f4d\u5bf9\u9f50\u5e76\u5220\u9664\u5197\u4f59\u6570\u636e\uff08&amp;<span class=\"code-snippet__number\">0000000011111111<\/span>\uff09\u3002<\/span><\/code><code><span class=\"code-snippet_outer\">        n = (n &amp; <span class=\"code-snippet__number\">0x00ff00ff<\/span>) + ((n <span class=\"code-snippet__meta\">&gt;&gt;&gt; <\/span><span class=\"code-snippet__number\">8<\/span>) &amp; <span class=\"code-snippet__number\">0x00ff00ff<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">        <span class=\"code-snippet__regexp\">\/\/<\/span> \u6bcf\u7ec4<span class=\"code-snippet__number\">16<\/span>\u4e2a\u4f4d\u7f6e\uff0c\u53f3\u79fb<span class=\"code-snippet__number\">16<\/span>\u4f4d\u5bf9\u9f50\u5e76\u5220\u9664\u5197\u4f59\u6570\u636e\uff08&amp;<span class=\"code-snippet__number\">000000000000000001111111111111111<\/span>\uff09\u3002<\/span><\/code><code><span class=\"code-snippet_outer\">        n = (n &amp; <span class=\"code-snippet__number\">0x0000ffff<\/span>) + ((n <span class=\"code-snippet__meta\">&gt;&gt; <\/span><span class=\"code-snippet__number\">16<\/span>) &amp; <span class=\"code-snippet__number\">0x0000ffff<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"code-snippet__regexp\">\/\/<\/span>&nbsp;\u6700\u540e<span class=\"code-snippet__number\">32<\/span>\u4f4d\u4e8c\u8fdb\u5236\u5168\u90e8\u5408\u5e76\u5230\u4e00\u7ec4\uff0c\u5373\u4e3a\u7b54\u6848\u3002<\/span><\/code><code><span class=\"code-snippet_outer\">        <span class=\"code-snippet__keyword\">return<\/span> n;<\/span><\/code><code><span class=\"code-snippet_outer\">    }<\/span><\/code><code><span class=\"code-snippet_outer\">}<\/span><\/code><\/pre>\n<\/section>\n<p><br  \/><\/p>\n<p style=\"margin-top: 8px;margin-bottom: 16px;font-weight: 600;font-size: 20px;white-space: normal;box-sizing: border-box;outline: 0px;font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;color: rgb(79, 79, 79);line-height: 28px;overflow-wrap: break-word;font-variant-ligatures: no-common-ligatures;text-align: start;background-color: rgb(255, 255, 255);\"><span style=\"font-size: 17px;\">\u590d\u6742\u5ea6\u5206\u6790<\/span><\/p>\n<p><br  \/><\/p>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;display: flex;flex-direction: column;justify-content: center;align-items: center;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"text-align: left;\"><strong>\u65f6\u95f4\u590d\u6742\u5ea6 O(logN)<\/strong>\uff1aN\u4e3a\u4e8c\u8fdb\u5236\u4f4d\u6570\uff0c\u8fd9\u91cc\u662f32\u3002\u5f531\u7684\u4e2a\u6570\u6bd4\u8f83\u591a\u7684\u65f6\u5019\uff0c\u8fd9\u79cd\u65b9\u5f0f\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u8981\u4f4e\u4e00\u4e9b\uff0c\u56fa\u5b9a\u7684\u53ea\u9700\u89815\u6b65\u3002<span style=\"text-align: justify;\">\u7a7a\u95f4\u590d\u6742\u5ea6&nbsp;O(1)<\/span><\/span><\/figure>\n<p><strong><span style=\"color: rgb(0, 0, 0);font-size: 16px;letter-spacing: normal;text-decoration: none solid rgb(0, 0, 0);\"><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;caret-color: rgb(0, 0, 0);\">\u7a7a\u95f4\u590d\u6742\u5ea6&nbsp;O(1)<\/span><\/span><\/strong><span style=\"color: rgb(0, 0, 0);font-size: 16px;letter-spacing: normal;text-decoration: none solid rgb(0, 0, 0);\"><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;caret-color: rgb(0, 0, 0);\"><\/span><\/span><\/p>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;display: flex;flex-direction: column;justify-content: center;align-items: center;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"text-align: left;\"><span style=\"text-align: justify;\"><\/span><\/span><span style=\"text-align: left;\"><span style=\"text-align: justify;\"><br  \/><\/span><\/span><\/figure>\n<p><br  \/><\/p>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;font-weight: bold;font-size: 1.3em;white-space: normal;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;text-align: left;text-size-adjust: auto;border-bottom: 2px solid rgb(239, 112, 96);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"margin-right: 3px;padding: 3px 10px 1px;outline: 0px;max-width: 100%;display: inline-block;background-color: rgb(239, 112, 96);color: rgb(255, 255, 255);border-top-right-radius: 3px;border-top-left-radius: 3px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u89e3\u6cd5\u56db\uff1aJDK Integer.bitCount(int i)<\/span><span style=\"outline: 0px;max-width: 100%;display: inline-block;vertical-align: bottom;border-bottom: 36px solid rgb(239, 235, 233);border-right: 20px solid transparent;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><\/span><\/h2>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;white-space: normal;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;text-size-adjust: auto;display: flex;flex-direction: column;justify-content: center;align-items: center;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/figure>\n<h3 style=\"margin-top: 8px;margin-bottom: 16px;font-weight: 600;font-size: 20px;white-space: normal;box-sizing: border-box;outline: 0px;font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;color: rgb(79, 79, 79);line-height: 28px;overflow-wrap: break-word;font-variant-ligatures: no-common-ligatures;text-align: start;background-color: rgb(255, 255, 255);\"><span style=\"font-size: 17px;\">\u89e3\u9898\u601d\u8def<\/span><\/h3>\n<h3 style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u89e3\u6cd54\u662f\u89e3\u6cd53\u7684\u4f18\u5316\u3002<\/h3>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"color: rgb(0, 128, 255);\">1. n = (n &amp; 0x55555555) + ((n &gt;&gt;&gt; 1) &amp; 0x55555555);<\/span><\/p>\n<ul class=\"list-paddingleft-1\" style=\"list-style-type: disc;\">\n<li>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">&nbsp; 0b11: 0b01 + 0b01 = 0b10 2\u4e2a<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">&nbsp; 0b10: 0b00 + 0b01 = 0b01 1\u4e2a<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">&nbsp; 0b01: 0b01 + 0b00 = 0b01 1\u4e2a<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">&nbsp; 0b00: 0b00 + 0b00 = 0b00 0\u4e2a<\/p>\n<\/li>\n<\/ul>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u4e24\u4e24\u4e00\u7ec4\u76f8\u52a0\u65f6\u6709\u4e0a\u8ff04\u79cd\u60c5\u51b5\uff0c\u4ece\u4e2d\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff1a<\/p>\n<ul class=\"list-paddingleft-1\" style=\"list-style-type: disc;\">\n<li>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">&nbsp; 0b10 = 0b11 - 0b01<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">&nbsp; 0b01 = 0b10 - 0b01<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">&nbsp; 0b01 = 0b01 - 0b00<\/p>\n<\/li>\n<li>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">&nbsp; 0b00 = 0b00 - 0b00<\/p>\n<\/li>\n<\/ul>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u5373\u8ba1\u7b97\u540e\u7684\u7ed3\u679c <span style=\"color: rgb(255, 104, 39);\">n&nbsp;= n&nbsp;- ((n &gt;&gt;&gt; 1) &amp; 0x55555555)<\/span> = (n &amp; 0x55555555) + ((n &gt;&gt;&gt; 1) &amp; 0x55555555)\uff0c<span style=\"color: rgb(255, 104, 39);\">\u4f18\u5316\u540e\u5c11\u4e86\u4e00\u6b21&amp;\u8fd0\u7b97<\/span>\u3002<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><strong>\u6211\u4eec\u53ef\u4ee5\u9a8c\u8bc1\u4e00\u4e0b1101\uff083\u4e2a1\uff09<\/strong>\uff1a<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u4f18\u5316\u524d\uff1a(n &amp; 0x55555555) + ((n &gt;&gt;&gt; 1) &amp; 0x55555555) = 0b01_01 + ((0b01_10) &amp; 0x5) = 0b01_01 + 0b01_00 = 0b10_01 = 2 + 1 = 3\u3002<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u4f18\u5316\u540e\uff1an - ((n &gt;&gt;&gt; 1) &amp; 0x5) = 0b11_01 - ((0b01_10) &amp; 0x5) = 0b11_01 - 0b_0100 = 0b10_01 = 2 + 1 = 3\u3002<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"color: rgb(0, 128, 255);\">2. n = (n &amp; 0x33333333) + ((n &gt;&gt;&gt; 2) &amp; 0x33333333);<\/span><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u65e0\u4f18\u5316<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"color: rgb(0, 128, 255);\">3. n = (n &amp; 0x0f0f0f0f) + ((n &gt;&gt;&gt; 4) &amp; 0x0f0f0f0f);<\/span><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u8fd9\u4e2a\u4f18\u5316\u65b9\u5f0f\u662f\u8fd9\u6837\u8003\u8651\u7684\uff0c\u56e0\u4e3a\u8fd9\u91cc\u521a\u597d\u662f8\u4e2a\u4f4d\u7f6e\u4e3a\u4e00\u7ec4\uff0c\u4e5f\u5c31\u662f\u4e00\u4e2a\u5b57\u8282\uff0c\u6700\u591a\u67098\u4e2a1\uff0c\u4e8c\u8fdb\u5236\u8868\u8fbe\u6700\u5927\u4e3a<span style=\"color: rgb(255, 104, 39);\">0000_1000<\/span>\uff0c\u6709\u540e\u97624\u4f4d\u5c31\u5df2\u7ecf\u591f\u7528\u4e86\uff0c\u6240\u4ee5\u53ef\u4ee5\u5148\u7528<span style=\"color: rgb(255, 104, 39);\">(n + (n &gt;&gt;&gt; 4))<\/span>\u628a\u540e\u97624\u4f4d\u7b97\u51fa\u6765\uff0c\u518d<span style=\"color: rgb(255, 104, 39);\">&amp;0f0f<\/span>\u5c06\u524d4\u4f4d\u6e05\u7a7a\uff0c<span style=\"color: rgb(0, 0, 0);\">\u4f18\u5316\u4e3a\uff1a<\/span><span style=\"color: rgb(255, 104, 39);\">n = (n + (n &gt;&gt;&gt; 4)) &amp; 0x0f0f0f0f\uff0c\u5c11\u4e86\u4e00\u6b21&amp;\u8fd0\u7b97\u3002<\/span><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"color: rgb(0, 128, 255);\">4. n = (n &amp; 0x00ff00ff) + ((n &gt;&gt;&gt; 8) &amp; 0x00ff00ff);<\/span><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u540c\u65b9\u6cd53\u4e00\u6837\uff0c\u8fd9\u91cc\u662f16\u4f4d\u4e3a\u4e00\u7ec4\uff0c\u6700\u591a16\u4e2a1\uff0c\u4e8c\u8fdb\u5236\u8868\u8fbe\u6700\u5927\u4e3a<span style=\"color: rgb(255, 104, 39);\">0000_0000_0001_0000<\/span>\uff0c\u524d8\u4f4d\u5168\u662f0\uff0c\u53ef\u4ee5\u6682\u65f6\u5ffd\u7565\uff0c\u53ef\u4ee5\u5148\u7528\u540e8\u4f4d\u76f8\u52a0\uff0c\u7136\u540e\u518d\u6e05\u7a7a\u524d8\u4f4d\u3002<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"color: rgb(0, 0, 0);\">\u4f18\u5316\u4e3a\uff1a<\/span><span style=\"color: rgb(255, 104, 39);\">n = (n + (n &gt;&gt;&gt; 8)) &amp; 0x00ff00ff\u3002<\/span><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"color: rgb(0, 128, 255);\">5. n = (n &amp; 0x0000ffff) + ((n &gt;&gt; 16) &amp; 0x0000ffff);<\/span><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u540c\u4e0a\uff0c\u4f18\u5316\u4e3a\uff1a<span style=\"color: rgb(255, 104, 39);\">n = (n + (n &gt;&gt;&gt; 16)) &amp; 0x0000ffff\u3002<\/span><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"color: rgb(0, 128, 255);\">6.<\/span> \u8fdb\u4e00\u6b65\u89c2\u5bdf\uff0c\u4f1a\u53d1\u73b0\uff0c\u7b2c4\u6b65\u7b2c5\u6b65\u7684\u6709\u6548\u4f4d\u90fd\u5728\u6700\u540e\u76848\u4f4d\u4e0a\uff0c\u524d\u9762\u7684\u90fd\u662f\u65e0\u6548\u4f4d\uff0c\u6240\u4ee5\u53ef\u4ee5\u5c06\u6e05\u7a7a\u64cd\u4f5c\u653e\u5230\u6700\u540e\uff0c\u53ea\u4fdd\u7559\u6700\u540e8\u4f4d\u6709\u6548\u4f4d\u7f6e\uff0c\u524d\u9762\u7684\u5168\u90e8\u6e05\u7a7a\uff0c\u5373 <span style=\"color: rgb(255, 104, 39);\">&amp;0b1111_111111 = &amp;0xff<\/span>\u3002<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\">\u518d\u8fdb\u4e00\u6b65\u89c2\u5bdf\uff0c\u7b2c4\u6b65\u6709\u6548\u4f4d\u662f\u6700\u540e5\u4f4d\uff0c\u7b2c5\u6b65\u6709\u6548\u4f4d\u662f\u6700\u540e6\u4f4d\uff08<span style=\"color: rgb(255, 104, 39);\">0b10_0000 = 32<\/span>\uff09\uff0c\u7b2c7\u4f4d\u7b2c8\u4f4d\u80af\u5b9a\u5168\u90e8\u4e3a0\uff0c\u6240\u4ee5\u4e5f\u53ef\u4ee5<span style=\"color: rgb(255, 104, 39);\">&amp;0b11_111111 = &amp;0x3f<\/span>\u3002<\/p>\n<p style=\"margin-bottom: 0px;padding-top: 8px;padding-bottom: 8px;outline: 0px;max-width: 100%;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<p style=\"margin-top: 8px;margin-bottom: 16px;font-weight: 600;font-size: 20px;white-space: normal;box-sizing: border-box;outline: 0px;font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun;color: rgb(79, 79, 79);line-height: 28px;overflow-wrap: break-word;font-variant-ligatures: no-common-ligatures;text-align: start;background-color: rgb(255, 255, 255);\"><span style=\"font-size: 17px;\">\u4ee3\u7801\u5b9e\u73b0<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"cs\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__keyword\">public<\/span> <span class=\"code-snippet__keyword\">class<\/span> <span class=\"code-snippet__title\">Solution<\/span> {<\/span><\/code><code><span class=\"code-snippet_outer\">   <span class=\"code-snippet__function\"><span class=\"code-snippet__keyword\">public<\/span> <span class=\"code-snippet__keyword\">int<\/span> <span class=\"code-snippet__title\">hammingWeight<\/span>(<span class=\"code-snippet__params\"><span class=\"code-snippet__keyword\">int<\/span> n<\/span>)<\/span> {<\/span><\/code><code><span class=\"code-snippet_outer\">    n = n - ((n &gt;&gt;&gt; <span class=\"code-snippet__number\">1<\/span>) &amp; <span class=\"code-snippet__number\">0x55555555<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">        n = (n &amp; <span class=\"code-snippet__number\">0x33333333<\/span>) + ((n &gt;&gt;&gt; <span class=\"code-snippet__number\">2<\/span>) &amp; <span class=\"code-snippet__number\">0x33333333<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">        n = (n + (n &gt;&gt;&gt; <span class=\"code-snippet__number\">4<\/span>)) &amp; <span class=\"code-snippet__number\">0x0f0f0f0f<\/span>;<\/span><\/code><code><span class=\"code-snippet_outer\">        n = n + (n &gt;&gt;&gt; <span class=\"code-snippet__number\">8<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">        n = n + (n &gt;&gt;&gt; <span class=\"code-snippet__number\">16<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">        <span class=\"code-snippet__keyword\">return<\/span> n &amp; <span class=\"code-snippet__number\">0x3f<\/span>;<\/span><\/code><code><span class=\"code-snippet_outer\">    }<\/span><\/code><code><span class=\"code-snippet_outer\">}<\/span><\/code><\/pre>\n<\/section>\n<p><br  \/><\/p>\n<p><span style=\"color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;text-align: left;caret-color: rgb(0, 0, 0);\">\u590d\u6742\u5ea6\u540c\u89e3\u6cd5\u4e09\u3002<\/span><\/p>\n<p style=\"display: none;\"><mp-style-type data-value=\"3\"><\/mp-style-type><\/p>\n<blockquote>\n<p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7:                 i\u4f59\u6570              <\/p>\n<\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee \u7f16\u5199\u4e00\u4e2a\u51fd\u6570\uff0c\u8f93\u5165\u662f\u4e00\u4e2a\u65e0\u7b26\u53f7\u6574\u6570\uff08\u4ee5\u4e8c\u8fdb\u5236\u4e32\u7684\u5f62\u5f0f\uff09\uff0c\u8fd4\u56de\u5176\u4e8c\u8fdb\u5236\u8868\u8fbe\u5f0f\u4e2d\u6570\u5b57\u4f4d\u6570\u4e3a &#8216;1&#8217; \u7684\u4e2a\u6570\uff08\u4e5f\u88ab\u79f0\u4e3a\u6c49\u660e\u91cd\u91cf\uff09\u3002 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":1522,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[22],"tags":[],"class_list":["post-1526","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-22"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043512301-150x150.jpeg","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043513167.png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043512301-300x128.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043512301.jpeg","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043513167.png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043512301-300x128.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043512301.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043512301.jpeg","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043513167.png","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043513167.png","id":"image1"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043514642.png","id":"image2"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043514642.png","id":"image3"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043515518.png","id":"image4"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528043515518.png","id":"image5"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"\u7b97\u6cd5","post_date":"2023-06-27","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":439,"next_post_id":2484,"next_post_title":"Java\u4e2d\u5c06 int[] \u6570\u7ec4 \u8f6c\u6362\u4e3a List\uff08ArrayList\uff09","previous_post_id":1489,"previous_post_title":"\u3010\u7b97\u6cd5\u9898\u89e3\u301114. \u6709\u6548\u7684\u62ec\u53f7","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/1526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1526"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/1526\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/1522"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}