Files
ClassFeedback/.claude/temp/prob_S0401P4.html

361 lines
38 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html data-page="problem_detail" data-layout="basic" class="layout--basic page--problem_detail theme--light nojs" lang="zh" data-app="Hydro">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="canonical" href="oj.qonnwolf.com/p/S0401P4"> <meta name="theme-color" content="#56758f">
<meta property="og:locale" content="zh" />
<meta property="og:title" content="S0401P4. 小杨的幸运数字 - 穹狼科创" />
<meta property="og:description" content="题目描述
小杨最近学了位运算。他发现有些正整数的二进制表示里恰好只有一个 1,比如 1(二进制 1)、2(10)、8(1000)——他把这样的数叫做幸运数(也就是 2
的幂)。
现在给定 n 个正整数..." />
<title>小杨的幸运数字 - 题目详情 - 穹狼科创</title>
<style>
body {
--font-family: "Open Sans", "Open Sans", "Seravek", "Segoe UI", "Verdana", "PingFang SC", "Hiragino Sans GB", "Lantinghei SC", "Microsoft Yahei", "WenQuanYi Micro Hei", "sans";
--code-font-family: "Source Code Pro", "monaco", "Source Code Pro", "Consolas", "Lucida Console", "monospace";
--font-ligatures: none !important;
}
.section{border-radius:10px}
#panel { display: flex; flex-direction: column; }
</style>
<link rel="stylesheet" media="all" href="/theme-4.58.3.css">
<script>
var _htmlNode = document.documentElement;
_htmlNode.className = _htmlNode.className.replace(' nojs', ' hasjs');
var UiContext = '{"cdn_prefix":"/","cdn_dynamic":false,"url_prefix":"/","ws_prefix":"/","hydroacFeatures":[],"blspHost":"wss://ws.hydrooj.com","constantVersion":"058f6069","domainId":"system","domain":{"_id":"system","lower":"system","owner":1,"name":"\u7A79\u72FC\u79D1\u521B","bulletin":"# \u2B50\u6B22\u8FCE\u4F7F\u7528\u7A79\u72FC\u79D1\u521B\u5728\u7EBF\u5B66\u4E60\u8BC4\u6D4B\u7CFB\u7EDF\u2B50\\r\\n\\r\\n## \uD83C\uDF89\uFE0F \u8BAD\u7EC3\u9898\u5355\\r\\n\\r\\n## <a>GESP\uFF1A</a><a href=\\"/training/6a29310829916258dec7763b\\" target=\\"_blank\\">\u4E00\u7EA7</a> | <a href=\\"/training/6a29335129916258dec7777a\\" target=\\"_blank\\">\u4E8C\u7EA7</a> | <a href=\\"/training/6a29337b29916258dec7777b\\" target=\\"_blank\\">\u4E09\u7EA7</a> | <a href=\\"/training/6a2933bd29916258dec7777d\\" target=\\"_blank\\">\u56DB\u7EA7</a> | <a href=\\"/training/6a2933f429916258dec77780\\" target=\\"_blank\\">\u4E94\u7EA7</a> | <a href=\\"/training/6870ca337e50189ceb63bf59\\" target=\\"_blank\\">\u516D\u7EA7</a> | <a href=\\"/training/6870caa37e50189ceb63bfa8\\" target=\\"_blank\\">\u4E03\u7EA7</a> | <a href=\\"/training/6a29341e29916258dec77784\\" target=\\"_blank\\">\u516B\u7EA7</a>\\r\\n## <a>CSP-JS\uFF1A</a><a href=\\"/d/CSP_J1/\\" target=\\"_blank\\">\u521D\u8D5B</a> | <a href=\\"/training/6a29346529916258dec77788\\" target=\\"_blank\\">\u590D\u8D5B</a> \\r\\n\\r\\n---\\r\\n## \uD83C\uDF89\uFE0F \u62D3\u5C55\u8BAD\u7EC3\\r\\n\\r\\n### A\uFF1A<a href=\\"/training/686f1e417e50189ceb630e98\\" target=\\"_blank\\">\u987A\u5E8F\u7ED3\u6784</a> | <a href=\\"/training/6a29350929916258dec77791\\" target=\\"_blank\\">\u5206\u652F\u7ED3\u6784</a> | <a href=\\"/training/6a29353229916258dec77792\\" target=\\"_blank\\">\u5FAA\u73AF\u7ED3\u6784</a> | <a href=\\"/training/6a29355e29916258dec77793\\" target=\\"_blank\\">\u7A77\u4E3E\u7B97\u6CD5</a> \\r\\n\\r\\n### B\uFF1A<a href=\\"/training/686f20057e50189ceb630fb6\\" target=\\"_blank\\">\u4E00\u7EF4\u6570\u7EC4</a> | <a href=\\"/training/6a2932b229916258dec77767\\" target=\\"_blank\\">\u5B57\u7B26\u4E32</a> | <a href=\\"/training/686f20f07e50189ceb630ff2\\" target=\\"_blank\\">\u4E8C\u7EF4\u6570\u7EC4</a> | <a href=\\"/training/686f21347e50189ceb630ffb\\" target=\\"_blank\\">\u51FD\u6570</a> | <a href=\\"/training/686f21597e50189ceb631020\\" target=\\"_blank\\">\u7ED3\u6784\u4F53</a> | <a href=\\"/training/68fb217e65d6c0e8cf403f39\\" target=\\"_blank\\">\u6570\u636E\u6392\u5E8F</a>\\r\\n\\r\\n\\r\\n\\r\\n### C\uFF1A<a href=\\"/training/686f23487e50189ceb631156\\" target=\\"_blank\\">\u9012\u63A8\u4E0E\u9012\u5F52</a> | <a href=\\"/training/686f23687e50189ceb6311a0\\" target=\\"_blank\\">\u8D2A\u5FC3</a> | <a href=\\"/training/686f23927e50189ceb6311a7\\" target=\\"_blank\\">\u8FDB\u5236\u8F6C\u6362</a> | <a href=\\"/training/686f23b87e50189ceb6311c6\\" target=\\"_blank\\">\u9AD8\u7CBE\u5EA6</a> | <a href=\\"/training/686f25767e50189ceb63121e\\" target=\\"_blank\\">\u4E8C\u5206</a> | <a href=\\"/training/6915a5c367ceffb06f6af7fa\\" target=\\"_blank\\">\u5206\u6CBB\u7B97\u6CD5</a>\\r\\n\\r\\n### D\uFF1A<a href=\\"/training/686f24377e50189ceb6311f3\\" target=\\"_blank\\">\u6DF1\u5EA6\u4F18\u5148\u641C\u7D22</a> | <a href=\\"/training/686f25527e50189ceb631219\\" target=\\"_blank\\">\u5E7F\u5EA6\u4F18\u5148\u641C\u7D22</a> | <a href=\\"/training/68883b387e50189ceb68b539\\" target=\\"_blank\\">\u524D\u7F00\u548C\u5DEE\u5206</a> | <a href=\\"/training/6a29330529916258dec77777\\" target=\\"_blank\\">\u52A8\u6001\u89C4\u5212</a> | <a href=\\"/training/686f26787e50189ceb63122e\\" target=\\"_blank\\">\u80CC\u5305</a> | <a href=\\"/training/68fb20fd65d6c0e8cf403f0c\\" target=\\"_blank\\">\u5176\u4ED6\u7B97\u6CD5</a>\\r\\n\\r\\n### E\uFF1A<a href=\\"/training/686f26b67e50189ceb631234\\" target=\\"_blank\\">\u56FE\u8BBA</a> | <a href=\\"/training/686f26e17e50189ceb63123c\\" target=\\"_blank\\">\u5E76\u67E5\u96C6</a> | <a href=\\"/training/686f27317e50189ceb631247\\" target=\\"_blank\\">\u533A\u95F4\u95EE\u9898</a> | <a href=\\"/training/686f27867e50189ceb631251\\" target=\\"_blank\\">\u6811\u53CA\u6811\u7684\u5E94\u7528</a> | <a href=\\"/training/686f27c17e50189ceb631257\\" target=\\"_blank\\">\u6570\u8BBA</a> | <a href=\\"/training/68fb219d65d6c0e8cf403f3a\\" target=\\"_blank\\">\u6570\u636E\u7ED3\u6784</a> \\r\\n---\\r\\n\\r\\n## \uD83C\uDF89\uFE0F <a href=\\"/d/Level_Test/\\" >\u6559\u5E08\u5B66\u751F\u80FD\u529B\u6D4B\u8BD5</a> | <a href=\\"https://oj.qonnwolf.com/d/Level_Test/p/A0001\\" >\u4FE1\u606F\u5B66\u6478\u5E95\u6D4B\u8BD5</a>\\r\\n\\r\\n---","roles":{"guest":"1","default":"87927944873247617","teacher":"2324866211840808047607","su_teacher":"2334089583877664274423","Other_Teacher":"2213715239984621994885","AI":"2186515631287987861489"},"avatar":"url:/file/2/qonnwolf-logo2.png","langs":"","share":"*","enableDownloadFirst":"on"},"extraTitleContent":"\u5C0F\u6768\u7684\u5E78\u8FD0\u6570\u5B57","SWConfig":{"preload":"","hosts":["http://oj.qonnwolf.com","https://oj.qonnwolf.com","oj.qonnwolf.com/","/"],"assets":[],"domains":[]}}';
var UserContext = '{"_id":339,"mail":"chengzi2508@bjcodemao.com","uname":"\u6A59\u5B50\u8001\u5E08","hashType":"hydro","priv":33554436,"regat":"2025-08-18T01:14:43.815Z","loginat":"2026-09-02T09:30:29.620Z","perm":"BigInt::2334089583877664274423","role":"su_teacher","scope":"BigInt::-1","tfa":false,"authn":false,"group":["\u6559\u5E08\u56E2\u961F","339"],"domains":[],"viewLang":"zh","timeZone":"Asia/Shanghai","codeLang":"cc.cc14o2","codeTemplate":"","avatar":"url:/file/339/.avatar.png","qq":"","gender":"0","bio":"\u9752\uFF0C\u53D6\u4E4B\u4E8E\u84DD\u800C\u9752\u4E8E\u84DD\u3002\u51B0\uFF0C\u6C34\u4E3A\u4E4B\u800C\u5BD2\u4E8E\u6C34\u3002\\r\\n","school":"\u7F16\u7A0B\u732B\u5927\u5B66","studentId":"111","backgroundImage":"/components/profile/doubao_avatar_new.png","unreadMsg":0,"badge":"","pinnedDomains":[],"rounded":false,"skipAnimate":false,"showTimeAgo":true,"fontFamily":"Open Sans","codeFontFamily":"Source Code Pro","theme":"light","preferredEditorType":"sv","showInvisibleChar":false,"formatCode":true,"coin_now":7480,"coin_all":7490,"displayName":"","rpInfo":{"problem":227.88533380626842},"nAccept":769,"nSubmit":791,"nLiked":0,"rp":227.88533380626842,"rank":20,"level":7,"join":true,"avatarUrl":"/file/339/.avatar.png"}';
</script>
</head>
<body>
<script type="text/javascript" src="/resource/058f6069/entry.js"></script>
<script type="text/javascript" src="/resource/4.58.3/lang-zh.js"></script>
<script type="text/javascript" src="/hydro-4.58.3.js"></script>
<nav class="nav slideout-menu" id="menu">
<div class="row"><div class="columns clearfix">
<ol class="nav__list nav__list--main clearfix">
<li class="nav__list-item">
<a href="/"><img class="nav__logo" src="/qonnwolf_new.png"></a>
</li> <li class="nav__list-item">
<a href="/" class="nav__item">
首页
</a>
</li>
<li class="nav__list-item">
<a href="/course" class="nav__item">
课程
</a>
</li>
<li class="nav__list-item">
<a href="/p" class="nav__item nav--active">
题库
</a>
</li>
<li class="nav__list-item">
<a href="/training" class="nav__item">
训练
</a>
</li>
<li class="nav__list-item">
<a href="/contest" class="nav__item">
比赛
</a>
</li>
<li class="nav__list-item">
<a href="/homework" class="nav__item">
作业
</a>
</li>
<li class="nav__list-item">
<a href="/record?uidOrName=339" class="nav__item">
评测记录
</a>
</li>
<li class="nav__list-item">
<a href="/domain/dashboard" class="nav__item">
管理域
</a>
</li>
</ol>
<ol class="nav__list nav__list--secondary clearfix">
<li class="nav__list-item" data-dropdown-pos="bottom right" data-dropdown-custom-class="nav__dropdown" data-dropdown-target="#menu-nav-user" data-dropdown-disabledconstrainToWindow data-dropdown-trigger-desktop-only>
<a href="/user/339" class="nav__item">橙子老师 <span class="icon icon-expand_more nojs--hide"></span></a>
<ol class="dropdown-target menu" id="menu-nav-user">
<li class="menu__item">
<a href="/user/339" class="menu__link">
<span class="icon icon-account--circle"></span> 我的资料
</a>
</li>
<li class="menu__item">
<a href="/home/messages" class="menu__link">
<span class="icon icon-comment--multiple"></span> 站内消息
</a>
</li>
<li class="menu__seperator"></li>
<li class="menu__item">
<a href="/home/settings/domain" class="menu__link">
<span class="icon icon-web"></span> @ 穹狼科创
</a>
</li>
<li class="menu__seperator"></li>
<li class="menu__item">
<a href="/home/settings/account" class="menu__link">
<span class="icon icon-wrench"></span> 账户设置
</a>
</li>
<li class="menu__item">
<a href="/home/settings/preference" class="menu__link">
<span class="icon icon-sliders"></span> 偏好设置
</a>
</li>
<li class="menu__item">
<a href="/home/security" class="menu__link">
<span class="icon icon-security"></span> 安全设置
</a>
</li>
<li class="menu__seperator"></li>
<li class="menu__item">
<a href="/home/domain" class="menu__link">
<span class="icon icon-web"></span> 我的域
</a>
</li>
<li class="menu__seperator"></li>
<li class="menu__item">
<a href="/logout" class="menu__link" name="nav_logout">
<span class="icon icon-logout"></span> 登出
</a>
</li>
</ol>
</li>
</ol>
</div></div>
</nav>
<nav class="nav--shadow"></nav>
<div class="slideout-panel" id="panel">
<div class="slideout-overlay"></div>
<div class="header--mobile">
<div class="row"><div class="columns clearfix">
<div class="float-left">
<a class="header--mobile__domain" href="/" target="_self">
<img src="/qonnwolf_new.png">
</a>
</div>
<div class="float-right">
<button type="button" class="header__hamburger">
<div class="hamburger hamburger--spin">
<span class="hamburger-box">
<span class="hamburger-inner"></span>
</span>
</div>
</button>
</div>
</div></div>
</div>
<div class="main">
<script>
</script>
<meta property="og:locale" content="zh" />
<meta property="og:title" content="S0401P4. 小杨的幸运数字 - 穹狼科创" />
<meta property="og:description" content="题目描述
小杨最近学了位运算。他发现有些正整数的二进制表示里恰好只有一个 1,比如 1(二进制 1)、2(10)、8(1000)——他把这样的数叫做幸运数(也就是 2
的幂)。
现在给定 n 个正整数..." />
<div class="row" data-sticky-parent>
<div class="medium-9 columns">
<div class="section">
<div class="section__header">
<h1 class="section__title">
<a href="/record/6a97e2b28499477a0418774e">
<span class="icon record-status--icon pass"></span>
<span class="record-status--text pass">100</span>
</a>
<form class="form--inline" action="" method="post">
<input type="hidden" name="star" value="true">
<input type="hidden" name="operation" value="star">
<button class="star" type="submit">
<span class="starred--hide"><span class="icon icon-star--outline" data-tooltip="收藏"></span></span>
<span class="starred--show"><span class="icon icon-star" data-tooltip="取消收藏"></span></span>
</button>
</form>
#S0401P4. 小杨的幸运数字
</h1>
</div>
<div class="section__body">
<ul class="problem__tags">
<span class="problem__tag-item">ID: 6968</span>
<span class="problem__tag-item icon icon-book">传统题</span>
<span class="problem__tag-item icon icon-stopwatch">1000ms</span>
<span class="problem__tag-item icon icon-comparison">256MiB</span>
<a class="problem__tag-item interactive" href="/record?pid=6968">尝试: 1</a>
<a class="problem__tag-item interactive" href="/record?pid=6968&amp;status=1">已通过: 1</a>
<span class="problem__tag-item">难度: 10</span>
<span class="problem__tag-item interactive">上传者: <span class="user-profile-link">
<img class="small user-profile-avatar v-center" loading="lazy" src="//cravatar.cn/avatar/6d2c246e0e74c79036c564ac6e90f1f5?d=mm&amp;s=64" width="20" height="20">
<a class="user-profile-name uname--lv10" href="/user/531">
moss
</a>
</span>
</span>
<span name="show_tags" class="problem__tag-item interactive nojs--hide icon icon-tag">标签&gt;</span><span class="problem__tag-item tags hasjs--hide">位运算</span><span class="problem__tag-item tags hasjs--hide">二进制</span><span class="problem__tag-item tags hasjs--hide">计数</span> </ul>
</div>
</div>
<div class="section">
<div class="problem-content-container"><div class="problem-content" data-marker-enabled>
<div class="section__header non-scratchpad--hide">
<h1 class="section__title">小杨的幸运数字</h1>
</div>
<div class="section__body typo richmedia" data-fragment-id="problem-description">
<h2 id="%E9%A2%98%E7%9B%AE%E6%8F%8F%E8%BF%B0" tabindex="-1">题目描述</h2>
<p>小杨最近学了位运算。他发现有些正整数的二进制表示里<strong>恰好只有一个 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn></mrow><annotation encoding="application/x-tex">1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span></span></span></span></strong>,比如 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn></mrow><annotation encoding="application/x-tex">1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span></span></span></span>(二进制 <code>1</code>)、<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn></mrow><annotation encoding="application/x-tex">2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">2</span></span></span></span>(<code>10</code>)、<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>8</mn></mrow><annotation encoding="application/x-tex">8</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">8</span></span></span></span>(<code>1000</code>)——他把这样的数叫做<strong>幸运数</strong>(也就是 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn></mrow><annotation encoding="application/x-tex">2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">2</span></span></span></span> 的幂)。</p>
<p>现在给定 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi></mrow><annotation encoding="application/x-tex">n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span></span></span></span> 个正整数,请你帮小杨统计两件事:</p>
<ol>
<li>这 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi></mrow><annotation encoding="application/x-tex">n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span></span></span></span> 个数中,幸运数的<strong>个数</strong>;</li>
<li>这 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi></mrow><annotation encoding="application/x-tex">n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span></span></span></span> 个数的二进制表示中,<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn></mrow><annotation encoding="application/x-tex">1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span></span></span></span> 的<strong>总个数</strong>。</li>
</ol>
<p>例如 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo separator="true">,</mo><mn>3</mn><mo separator="true">,</mo><mn>4</mn><mo separator="true">,</mo><mn>7</mn><mo separator="true">,</mo><mn>8</mn></mrow><annotation encoding="application/x-tex">1, 3, 4, 7, 8</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">1</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">3</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">4</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">7</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">8</span></span></span></span> 中:<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo separator="true">,</mo><mn>4</mn><mo separator="true">,</mo><mn>8</mn></mrow><annotation encoding="application/x-tex">1, 4, 8</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">1</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">4</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">8</span></span></span></span> 是幸运数,共 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>3</mn></mrow><annotation encoding="application/x-tex">3</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">3</span></span></span></span> 个;二进制中 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn></mrow><annotation encoding="application/x-tex">1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span></span></span></span> 的总个数为 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>+</mo><mn>2</mn><mo>+</mo><mn>1</mn><mo>+</mo><mn>3</mn><mo>+</mo><mn>1</mn><mo>=</mo><mn>8</mn></mrow><annotation encoding="application/x-tex">1 + 2 + 1 + 3 + 1 = 8</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">2</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">3</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">8</span></span></span></span>。</p>
<h2 id="%E8%BE%93%E5%85%A5%E6%A0%BC%E5%BC%8F" tabindex="-1">输入格式</h2>
<p>第一行一个整数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi></mrow><annotation encoding="application/x-tex">n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span></span></span></span>;第二行 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi></mrow><annotation encoding="application/x-tex">n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span></span></span></span> 个正整数,用空格隔开。</p>
<h2 id="%E8%BE%93%E5%87%BA%E6%A0%BC%E5%BC%8F" tabindex="-1">输出格式</h2>
<p>两行:第一行幸运数的个数;第二行所有数的二进制中 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn></mrow><annotation encoding="application/x-tex">1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span></span></span></span> 的总个数。</p>
<h2 id="%E6%95%B0%E6%8D%AE%E8%8C%83%E5%9B%B4" tabindex="-1">数据范围</h2>
<ul>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><mi>n</mi><mo>≤</mo><mn>1000</mn></mrow><annotation encoding="application/x-tex">1 \le n \le 1000</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7804em;vertical-align:-0.136em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≤</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≤</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1000</span></span></span></span></li>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><msub><mi>a</mi><mi>i</mi></msub><mo>≤</mo><msup><mn>10</mn><mn>9</mn></msup></mrow><annotation encoding="application/x-tex">1 \le a_i \le 10^9</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7804em;vertical-align:-0.136em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≤</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.786em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≤</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">9</span></span></span></span></span></span></span></span></span></span></span></li>
</ul>
<h2 id="%E6%A0%B7%E4%BE%8B-%231" tabindex="-1">样例 #1</h2>
<pre><code class="language-input1">5
1 3 4 7 8
</code></pre>
<pre><code class="language-output1">3
8
</code></pre>
<h2 id="%E6%A0%B7%E4%BE%8B-%232" tabindex="-1">样例 #2</h2>
<pre><code class="language-input2">3
1024 999 536870912
</code></pre>
<pre><code class="language-output2">2
10
</code></pre>
</div> </div></div>
</div>
</div>
<div class="medium-3 columns"><div data-sticky="large">
<div class="section side section--problem-sidebar">
<div>
<ol class="menu">
<li class="menu__item scratchpad--hide nojs--hide"><a class="menu__link highlight" name="problem-sidebar__open-scratchpad" href="javascript:;" data-global-hotkey="alt+e">
<span class="icon icon-enlarge"></span> 进入在线编程模式 (Alt+E)
</a></li>
<li class="menu__item non-scratchpad--hide"><a class="menu__link" name="problem-sidebar__quit-scratchpad" href="javascript:;" data-global-hotkey="alt+q">
<span class="icon icon-enlarge"></span> 退出在线编程模式 (Alt+Q)
</a></li>
<li class="menu__item scratchpad--hide"><a class="menu__link" href="/p/S0401P4/submit">
<span class="icon icon-send"></span> 递交
</a></li>
<li class="menu__item">
<form method="post" action="/p/6968">
<input type="hidden" name="operation" value="rejudge">
<button type="submit" class="menu__link" name="problem-sidebar__rejudge">
<span class="icon icon-refresh"></span> 重测整题
</button>
</form>
</li>
<li class="menu__seperator"></li>
<li class="menu__item"><a class="menu__link" href="/p/S0401P4/solution">
<span class="icon icon-comment--text"></span> 题解 (0) </a></li>
<li class="menu__item"><a class="menu__link" href="/p/S0401P4/files">
<span class="icon icon-file"></span> 文件
</a></li>
<li class="menu__item"><a class="menu__link" href="/p/S0401P4/stat">
<span class="icon icon-statistics"></span> 统计
</a></li>
<li class="menu__seperator"></li>
<li class="menu__item"><a class="menu__link" href="/p/S0401P4/edit">
<span class="icon icon-edit"></span> 编辑
</a></li>
<li class="menu__item"><a class="menu__link" href="/p/S0401P4/config">
<span class="icon icon-settings"></span> 评测设置
</a></li>
<li class="menu__seperator nojs--hide"></li>
<li class="menu__item nojs--hide"><a class="menu__link" href="javascript:;" name="problem-sidebar__download">
<span class="icon icon-download"></span> 下载
</a></li>
<li class="menu__item nojs--hide"><a class="menu__link" href="javascript:;" name="problem-sidebar__copy">
<span class="icon icon-copy"></span> 复制
</a></li>
</ol>
</div>
</div>
<div class="section side">
<div class="section__header">
<h1 class="section__title">相关</h1>
</div>
<div class="section__body typo">
<p>在以下作业中: </p><p><a href="/homework/6a8c6a8b8499477a04169f85">01 基础回顾 - 课堂练习</a></p> </div>
</div>
</div></div>
</div>
<div style="display:none" class="outer-loader-container"><div class="loader"></div></div>
<div class="scratchpad-container" style="display:none">
<div style="display:none" class="loader-container"><div class="loader"></div></div>
<div id="scratchpad" style="opacity:0"></div>
</div>
</div>
<div class="footer">
<div class="row">
<div class="columns">
<div class="footer__extra-link clearfix">
<div class="footer__extra-left">
<ol class="clearfix">
<li class="footer__extra-link-item"><a href="/record">评测队列</a></li>
<li class="footer__extra-link-item"><a href="/status">服务状态</a></li>
<li class="footer__extra-link-item">
<a href="/legacy?legacy=true">兼容模式</a>
</li>
<li class="footer__extra-link-item nojs--hide" data-dropdown-target="#menu-footer-theme">
<span><span class="icon icon-global"></span> 主题 <span
class="icon icon-expand_less"></span></span>
<ol class="dropdown-target menu" id="menu-footer-theme">
<li class="menu__item"><a class="menu__link" href="/set_theme/light">亮色</a></li>
<li class="menu__item"><a class="menu__link" href="/set_theme/dark">暗色</a></li>
</ol>
</li>
</ol>
</div>
<div class="footer__extra-right">
<ol class="clearfix"><li class="footer__extra-link-item"></li><li class="footer__extra-link-item"></li><li class="footer__extra-link-item">Worker 0, 43ms</li>
<!-- Prepare 4ms -->
<!-- Method 2ms -->
<li class="footer__extra-link-item">Powered by <a href="https://hydro.js.org">Hydro v5.0.3</a> </li>
</ol>
</div>
</div>
</div>
</div>
</div></div>
<script>
var UiContextNew = '{"problemId":"S0401P4","problemNumId":6968,"codeLang":"cc.cc14o2","codeTemplate":"","pdoc":{"_id":"6a9253fc8499477a04180de7","content":"{\\"zh\\":\\"## \u9898\u76EE\u63CF\u8FF0\\\\n\\\\n\u5C0F\u6768\u6700\u8FD1\u5B66\u4E86\u4F4D\u8FD0\u7B97\u3002\u4ED6\u53D1\u73B0\u6709\u4E9B\u6B63\u6574\u6570\u7684\u4E8C\u8FDB\u5236\u8868\u793A\u91CC**\u6070\u597D\u53EA\u6709\u4E00\u4E2A $1$**\uFF0C\u6BD4\u5982 $1$\uFF08\u4E8C\u8FDB\u5236 `1`\uFF09\u3001$2$\uFF08`10`\uFF09\u3001$8$\uFF08`1000`\uFF09\u2014\u2014\u4ED6\u628A\u8FD9\u6837\u7684\u6570\u53EB\u505A**\u5E78\u8FD0\u6570**\uFF08\u4E5F\u5C31\u662F $2$ \u7684\u5E42\uFF09\u3002\\\\n\\\\n\u73B0\u5728\u7ED9\u5B9A $n$ \u4E2A\u6B63\u6574\u6570\uFF0C\u8BF7\u4F60\u5E2E\u5C0F\u6768\u7EDF\u8BA1\u4E24\u4EF6\u4E8B\uFF1A\\\\n\\\\n1. \u8FD9 $n$ \u4E2A\u6570\u4E2D\uFF0C\u5E78\u8FD0\u6570\u7684**\u4E2A\u6570**\uFF1B\\\\n2. \u8FD9 $n$ \u4E2A\u6570\u7684\u4E8C\u8FDB\u5236\u8868\u793A\u4E2D\uFF0C$1$ \u7684**\u603B\u4E2A\u6570**\u3002\\\\n\\\\n\u4F8B\u5982 $1, 3, 4, 7, 8$ \u4E2D\uFF1A$1, 4, 8$ \u662F\u5E78\u8FD0\u6570\uFF0C\u5171 $3$ \u4E2A\uFF1B\u4E8C\u8FDB\u5236\u4E2D $1$ \u7684\u603B\u4E2A\u6570\u4E3A $1 + 2 + 1 + 3 + 1 = 8$\u3002\\\\n\\\\n## \u8F93\u5165\u683C\u5F0F\\\\n\\\\n\u7B2C\u4E00\u884C\u4E00\u4E2A\u6574\u6570 $n$\uFF1B\u7B2C\u4E8C\u884C $n$ \u4E2A\u6B63\u6574\u6570\uFF0C\u7528\u7A7A\u683C\u9694\u5F00\u3002\\\\n\\\\n## \u8F93\u51FA\u683C\u5F0F\\\\n\\\\n\u4E24\u884C\uFF1A\u7B2C\u4E00\u884C\u5E78\u8FD0\u6570\u7684\u4E2A\u6570\uFF1B\u7B2C\u4E8C\u884C\u6240\u6709\u6570\u7684\u4E8C\u8FDB\u5236\u4E2D $1$ \u7684\u603B\u4E2A\u6570\u3002\\\\n\\\\n## \u6570\u636E\u8303\u56F4\\\\n\\\\n- $1 \\\\\\\\le n \\\\\\\\le 1000$\\\\n- $1 \\\\\\\\le a_i \\\\\\\\le 10^9$\\\\n\\\\n## \u6837\u4F8B #1\\\\n\\\\n```input1\\\\n5\\\\n1 3 4 7 8\\\\n```\\\\n\\\\n```output1\\\\n3\\\\n8\\\\n```\\\\n\\\\n## \u6837\u4F8B #2\\\\n\\\\n```input2\\\\n3\\\\n1024 999 536870912\\\\n```\\\\n\\\\n```output2\\\\n2\\\\n10\\\\n```\\\\n\\"}","owner":531,"domainId":"system","docType":10,"docId":6968,"title":"\u5C0F\u6768\u7684\u5E78\u8FD0\u6570\u5B57","tag":["\u4F4D\u8FD0\u7B97","\u4E8C\u8FDB\u5236","\u8BA1\u6570"],"hidden":true,"nSubmit":1,"nAccept":1,"data":[{"_id":"std.cpp","name":"std.cpp","size":439,"lastModified":"2026-08-29T03:37:32.104Z","etag":"L2RhdGEvZmlsZS9oeWRyby92aGEvZG1meG80M2VlY3NoYmI1MnJsMHh6LmNwcA=="},{"_id":"test1.in","name":"test1.in","size":12,"lastModified":"2026-08-29T03:37:32.108Z","etag":"L2RhdGEvZmlsZS9oeWRyby9ibmIvY3ZzbWZ1dGVzbW01dGVvdmRoaGtoLmlu"},{"_id":"test1.out","name":"test1.out","size":4,"lastModified":"2026-08-29T03:37:32.112Z","etag":"L2RhdGEvZmlsZS9oeWRyby9oaWMvbnRhNnYwZnlwcXJnczRydG1lMzBzLm91dA=="},{"_id":"test2.in","name":"test2.in","size":21,"lastModified":"2026-08-29T03:37:32.116Z","etag":"L2RhdGEvZmlsZS9oeWRyby9wYXgvYm45YmtoZW84d3MwaHM3ZjBvcGI5Lmlu"},{"_id":"test2.out","name":"test2.out","size":5,"lastModified":"2026-08-29T03:37:32.120Z","etag":"L2RhdGEvZmlsZS9oeWRyby92bHAvMDBncnFob3RneTU3emJiM3JzaXQ1Lm91dA=="},{"_id":"test3.in","name":"test3.in","size":19,"lastModified":"2026-08-29T03:37:32.123Z","etag":"L2RhdGEvZmlsZS9oeWRyby9yZ3kvdHByM2d0ZW9rcTl3b2R4bWJwb3g0Lmlu"},{"_id":"test3.out","name":"test3.out","size":5,"lastModified":"2026-08-29T03:37:32.128Z","etag":"L2RhdGEvZmlsZS9oeWRyby9pZHIvZmxzaHN3aWFzZ2ZyY3dqZHN1dm53Lm91dA=="},{"_id":"test4.in","name":"test4.in","size":4,"lastModified":"2026-08-29T03:37:32.132Z","etag":"L2RhdGEvZmlsZS9oeWRyby9zdnMvZ2Ztb3h1Zmx5cGlseHFkd3d1d2dwLmlu"},{"_id":"test4.out","name":"test4.out","size":4,"lastModified":"2026-08-29T03:37:32.135Z","etag":"L2RhdGEvZmlsZS9oeWRyby9ldHMvdnQ3ZG9ta3k3dGYwZjdqd3hqYjJ6Lm91dA=="},{"_id":"test5.in","name":"test5.in","size":13,"lastModified":"2026-08-29T03:37:32.139Z","etag":"L2RhdGEvZmlsZS9oeWRyby80MzQvcnlpd2dnOW9xempzYXB5MGlpZDZsLmlu"},{"_id":"test5.out","name":"test5.out","size":5,"lastModified":"2026-08-29T03:37:32.142Z","etag":"L2RhdGEvZmlsZS9oeWRyby8wbzAveWVhbm0zN2p5bWl2eXBqeXVrbHgzLm91dA=="},{"_id":"test6.in","name":"test6.in","size":9882,"lastModified":"2026-08-29T03:37:32.146Z","etag":"L2RhdGEvZmlsZS9oeWRyby8zeTAvMGt1YTRxdGl5Y2RmenV5a3F2ZDA5Lmlu"},{"_id":"test6.out","name":"test6.out","size":8,"lastModified":"2026-08-29T03:37:32.150Z","etag":"L2RhdGEvZmlsZS9oeWRyby9jMGsvamRkMG1kZXhyNjM5cjJ2MWswYXBwLm91dA=="}],"additional_file":[],"pid":"S0401P4","difficulty":0,"html":false,"stats":{"AC":1,"s100":1},"config":{"count":6,"memoryMin":256,"memoryMax":256,"timeMin":1000,"timeMax":1000,"type":"default","langs":["bash","c","cc","cc.cc98","cc.cc98o2","cc.cc11","cc.cc11o2","cc.cc14","cc.cc14o2","cc.cc17","cc.cc17o2","cc.cc20","cc.cc20o2","pas","java","kt","kt.jvm","py","py.py2","py.py3","py.pypy3","php","rs","hs","js","go","rb","cs","r"]}},"canViewRecord":true,"postSubmitUrl":"/p/6968/submit","getSubmissionsUrl":"/record?fullStatus=true&pid=6968","getRecordDetailUrl":"/record/%7Brid%7D","pretestConnUrl":"record-conn?pretest=1&uidOrName=339&pid=6968&domainId=system"}';
var UserContextNew = '{}';
</script>
</body>
</html>