結果

問題 No.1185 完全な3の倍数
ユーザー boutarou
提出日時 2020-08-24 07:41:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 82,468 KB
実行使用メモリ 75,712 KB
最終ジャッジ日時 2024-11-24 09:48:42
合計ジャッジ時間 3,250 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()

n = int(s)
num = len(s)

ans = 0

for i in range(4 ** num):
    now = i
    cnt = 0
    for j in range(num):
        cnt *= 10
        cnt += (now % 4) * 3
        now //= 4
    if (cnt <= n):
        ans += 1

for i in range(10, min(100, n + 1)):
    a = i % 10
    b = i // 10
    if ((a % 3 == 1 and b % 3 == 2) or (a % 3 == 2 and b % 3 == 1)):
        ans += 1

print(ans - 4)
0