結果

問題 No.1185 完全な3の倍数
ユーザー tn
提出日時 2022-03-10 15:57:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 351 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 75,776 KB
最終ジャッジ日時 2024-09-14 16:43:40
合計ジャッジ時間 5,352 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
n = int(input())

cnt = 0

for i in range(10, min(100, n + 1)):
    cnt = cnt + 1 if (int(str(i)[0]) + int(str(i)[1])) % 3 == 0 and i % 3 == 0 else cnt
    
if n > 100:
    numList = ['0', '3', '6', '9']
    for j in range(4 ** len(str(n))):
        st = ''
        q = j
        for k in range(len(str(n))):
            st += numList[q % 4]
            q = (q - q % 4) // 4
        s = int(st)
        if s <= n and s > 100:
            cnt += 1
    
print(cnt)
0