結果

問題 No.1185 完全な3の倍数
ユーザー roaris
提出日時 2020-08-22 16:36:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 352 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 76,556 KB
最終ジャッジ日時 2024-11-24 09:43:28
合計ジャッジ時間 6,078 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def dfs(d, now):
    global ans
    
    if d==10:
        if 10<=now<=N:
            ans += 1
        return
    
    for n in [0, 3, 6, 9]:
        dfs(d+1, 10*now+n)

N = int(input())
ans = 0
dfs(0, 0)

for i in range(10, 100):
    if i%3==0 and (i//10%3!=0 or i%10%3!=0) and i<=N:
        ans += 1

print(ans)
0