数 1 的个数

Luogu
IDLGB2154
Time1000ms
Memory512MB
DifficultyP1
循环结构
给定一个十进制正整数 $n$,写下从 $1$ 到 $n$ 的所有整数,然后数一下其中出现的数字 $1$ 的个数。 例如: - 当 $n=2$ 时,写下 $1,2$,这样只出现了 $1$ 个 $1$; - 当 $n=12$ 时,写下 $1,2,3,4,5,6,7,8,9,10,11,12$,这样出现了 $5$ 个 $1$。 ## Input 正整数 $n$。$1 \le n \le 10000$。 ## Output 一个正整数,即 $1$ 的个数。 [samples]
Samples
Input #1
12
Output #1
5
API Response (JSON)
{
  "problem": {
    "name": "数 1 的个数",
    "description": {
      "content": "给定一个十进制正整数 $n$,写下从 $1$ 到 $n$ 的所有整数,然后数一下其中出现的数字 $1$ 的个数。 例如: - 当 $n=2$ 时,写下 $1,2$,这样只出现了 $1$ 个 $1$; - 当 $n=12$ 时,写下 $1,2,3,4,5,6,7,8,9,10,11,12$,这样出现了 $5$ 个 $1$。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P1"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGB2154"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给定一个十进制正整数 $n$,写下从 $1$ 到 $n$ 的所有整数,然后数一下其中出现的数字 $1$ 的个数。\n\n例如:\n- 当 $n=2$ 时,写下 $1,2$,这样只出现了 $1$ 个 $1$;\n- 当 $n=12$ 时,写下 $1,2,3,4,5,6,7,8,9,10,11,12$,这样出现了 $5$ 个 $1$。\n\n## Input\n\n正整数 $n$。$1 \\le n \\le 10000...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments