Files
PAT/html/a1049.html
T

20 lines
696 B
HTML

<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h1>1049. Counting Ones (30)</h1>
<div id="problemContent">
<p>The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1's in 1, 10, 11, and 12.</p>
<p><b>
Input Specification:
</b></p>
<p>Each input file contains one test case which gives the positive N (&lt;=2<sup>30</sup>).</p>
<p><b>
Output Specification:
</b></p>
<p>For each test case, print the number of 1's in one line.</p>
<b>Sample Input:</b><pre>
12
</pre>
<b>Sample Output:</b><pre>
5
</pre>
</div>