結果
問題 |
No.1185 完全な3の倍数
|
ユーザー |
|
提出日時 | 2021-05-03 12:55:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 588 bytes |
コンパイル時間 | 134 ms |
コンパイル使用メモリ | 82,476 KB |
実行使用メモリ | 54,020 KB |
最終ジャッジ日時 | 2024-07-22 02:50:03 |
合計ジャッジ時間 | 2,932 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
import math import sys def resolve(): nstr = input() length = len(nstr) n = int(nstr) if length == 2: print(n//3-3) return result = 30 if length - 3 > 0: result += 16*(4**(length-3)-1) head = int(nstr[0]) result += (head-1)//3 * 4**(length-1) if head%3 != 0: print(result) return for i, c in zip(range(length-1,0,-1),nstr[1:]): if int(c) == 0: continue result += (int(c)+2)//3 * 4**(i-1) if int(c)%3 != 0: break else: result += 1 print(result) resolve()