結果

問題 No.1185 完全な3の倍数
ユーザー mlihua09
提出日時 2020-08-22 13:52:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 433 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,032 KB
最終ジャッジ日時 2024-11-24 09:26:40
合計ジャッジ時間 4,872 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

n = len(str(N))

from itertools import product

if N < 100:
    
    
    print(max(N // 3 - 3, 0))
    
else:
    
    ans = 100 // 3 - 3
    
    
    for i in range(3, n):
        
        ans += 3 * 4 ** (i - 1)
    
    
    
    for i in product('0369', repeat=n):
        
        if i[0] != '0':
            
            if int(''.join(i)) <= N:
                ans += 1
                
    
    print(ans)
0