結果
問題 |
No.1185 完全な3の倍数
|
ユーザー |
|
提出日時 | 2021-05-03 12:57:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 588 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-07-22 02:53:13 |
合計ジャッジ時間 | 2,732 ms |
ジャッジサーバーID (参考情報) |
judge5 / 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()