問題一覧 > 通常問題

No.220 The World's Something 2

レベル : / AI推定難易度 : 1100 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 256
作問者 : data9824
お気に入りにしたユーザー ProblemId : 577 / 自分の提出
問題文最終更新日: 2026-06-25 02:27:39
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 107 (順位表) の他の問題:

Problem Statement

Among the integers between \(1\) and \(10^P\) inclusive, output the count of numbers that are multiples of 3 or numbers containing a 3.

Note that a number that is both a multiple of 3 and a number containing a 3 is counted once.

Here, a "number containing a 3" is a number that has at least one digit equal to 3 in its decimal representation.

Input

P

\(1 \leq P \leq 19\)

Output

Output the count. Print a newline at the end.

Sample

Sample 1
Input
1
Output
3

Between 1 and 10 inclusive, the multiples of 3 and numbers containing a 3 are 3, 6, 9, for a total of 3 numbers.

Sample 2
Input
2
Output
45

Between 1 and 100 inclusive, the multiples of 3 and numbers containing a 3 are 3, 6, 9, 12, 13, 15, 18, 21, 23, 24, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 42, 43, 45, 48, 51, 53, 54, 57, 60, 63, 66, 69, 72, 73, 75, 78, 81, 83, 84, 87, 90, 93, 96, 99, for a total of 45 numbers.

Sample 3
Input
19
Output
9099432188218005273

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。