L. Chemistry Exam

Codeforces
IDCF10216L
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
NCD students can make new inventions, discover new theories, and face big challenges, but they can't pass the chemistry test. In the last test, all the questions were $\"T r u e\"$ or $\"F a l s e\"$ questions. After the exam, it turned out that all the answers were correct. Each student represents his exam paper as a decimal number, where each bit is an answer to a question. For example, if Hasan's paper was $5$, which is ($101_2$) in binary, this means that he answered the $1_{s t}$ and $3_{r d}$ questions as $\"T r u e\"$, and the rest as $\"F a l s e\"$, and he got $2$ marks in the exam. After the test, all the students went insane because the test was very hard. So they asked you to give them their marks. The first line contains the number of test cases $T$. For each test case, the first line contains integer $N$ ($1 <= N <= 10^5$) the number of students. The next line contains $N$ space separated integers $A_i$ ($1 <= A_i <= 10^9$) the mark for each student $i$. For each test case print $N$ integers the number of correct questions each student has answered. ## Input The first line contains the number of test cases $T$.For each test case, the first line contains integer $N$ ($1 <= N <= 10^5$) the number of students.The next line contains $N$ space separated integers $A_i$ ($1 <= A_i <= 10^9$) the mark for each student $i$. ## Output For each test case print $N$ integers the number of correct questions each student has answered. [samples]
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case $ k \in \{1, \dots, T\} $: - Let $ N_k \in \mathbb{Z} $ denote the number of students. - Let $ A_k = (a_{k,1}, a_{k,2}, \dots, a_{k,N_k}) $ be a sequence of integers, where each $ a_{k,i} $ represents the decimal encoding of a student’s answer sheet. **Constraints** 1. $ 1 \le T \le 10^4 $ (implied by context) 2. For each test case $ k $: - $ 1 \le N_k \le 10^5 $ - $ 1 \le a_{k,i} \le 10^9 $ for all $ i \in \{1, \dots, N_k\} $ **Objective** For each student $ i $ in test case $ k $, compute the number of 1-bits in the binary representation of $ a_{k,i} $: $$ \text{score}_{k,i} = \text{popcount}(a_{k,i}) = \sum_{j=0}^{\lfloor \log_2 a_{k,i} \rfloor} \left\lfloor \frac{a_{k,i}}{2^j} \right\rfloor \bmod 2 $$
API Response (JSON)
{
  "problem": {
    "name": "L. Chemistry Exam",
    "description": {
      "content": "NCD students can make new inventions, discover new theories, and face big challenges, but they can't pass the chemistry test. In the last test, all the questions were $\\\"T r u e\\\"$ or $\\\"F a l s e\\\"$",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10216L"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "NCD students can make new inventions, discover new theories, and face big challenges, but they can't pass the chemistry test.\n\nIn the last test, all the questions were $\\\"T r u e\\\"$ or $\\\"F a l s e\\\"$...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, T\\} $:  \n- Let $ N_k \\in \\mathbb{Z} $ denote the number of students.  \n- Let $ A_k = (a...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments