# 145. 十亿内的可翻转数(How many reversible numbers are there below one-billion?)

## 一、数位为偶数(包括二、四，六、八) ## 二、数位为$$4n+1$$型(包括一、五、九) ## 三、数位为$$4n+3$$型(包括三、七) ## 四、结论

• 当数位$$d$$为偶数时，则总的选择数为$$20*30^{d/2-1}$$
• 当数位$$d$$$$4n+1$$型时，不存在符合条件的可翻转数
• 当数位$$d$$$$4n+3$$型时，则总的选择数为$$5*20*(25*20)^{(d-3)/4}$$

# time cost = 4.89 µs ± 19 ns

def reversible_numbers(d):
r = d % 4
if r == 0 or r == 2:
return 20*30**(d//2-1)
elif r == 3:
return 100*(500)**((d-3)//4)
else:
return 0

def main():
ans = sum([reversible_numbers(x) for x in range(2,10)])
return ans
{"ft_lang_label":"__label__zh","ft_lang_prob":0.86582506,"math_prob":0.99997747,"size":2456,"snap":"2021-31-2021-39","text_gpt3_token_len":2058,"char_repetition_ratio":0.08890702,"word_repetition_ratio":0.0,"special_character_ratio":0.34201956,"punctuation_ratio":0.048661802,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9999105,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12],"im_url_duplicate_count":[null,2,null,2,null,2,null,2,null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-08-04T14:43:18Z\",\"WARC-Record-ID\":\"<urn:uuid:a53525c6-8e40-45de-8c63-1a6adf1acca0>\",\"Content-Length\":\"16417\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a6bc83c7-6ba5-4cb4-b946-be64eb5dbeda>\",\"WARC-Concurrent-To\":\"<urn:uuid:b7a3c4f3-3495-4ac3-afb5-e839607f4728>\",\"WARC-IP-Address\":\"167.172.139.120\",\"WARC-Target-URI\":\"https://pe.metaquant.org/pe145.html\",\"WARC-Payload-Digest\":\"sha1:TWR5KPHJ36TKERWULIHLVZ3WKOPLPPWZ\",\"WARC-Block-Digest\":\"sha1:AUJNB4ODTDE25TGENVWFDVPMUUXY5TAB\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046154878.27_warc_CC-MAIN-20210804142918-20210804172918-00512.warc.gz\"}"}