結果

問題 No.220 世界のなんとか2
ユーザー _polarbear08_polarbear08
提出日時 2018-09-01 17:22:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 33 ms / 1,000 ms
コード長 700 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 11,848 KB
実行使用メモリ 10,124 KB
最終ジャッジ日時 2023-10-19 12:06:59
合計ジャッジ時間 1,667 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,124 KB
testcase_01 AC 30 ms
10,124 KB
testcase_02 AC 31 ms
10,124 KB
testcase_03 AC 33 ms
10,124 KB
testcase_04 AC 31 ms
10,124 KB
testcase_05 AC 30 ms
10,124 KB
testcase_06 AC 30 ms
10,124 KB
testcase_07 AC 29 ms
10,124 KB
testcase_08 AC 29 ms
10,124 KB
testcase_09 AC 29 ms
10,124 KB
testcase_10 AC 29 ms
10,124 KB
testcase_11 AC 31 ms
10,124 KB
testcase_12 AC 29 ms
10,124 KB
testcase_13 AC 32 ms
10,124 KB
testcase_14 AC 29 ms
10,124 KB
testcase_15 AC 30 ms
10,124 KB
testcase_16 AC 30 ms
10,124 KB
testcase_17 AC 29 ms
10,124 KB
testcase_18 AC 31 ms
10,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

p = ni()

# 3がつく数の個数を調べる
dp = [[0,0] for _ in range(p+1)]
dp[0][0] = 1
dp[0][1] = 0
for pi in range(p):
    dp[pi+1][0] = dp[pi][0] * 9
    dp[pi+1][1] = dp[pi][1] * 10 + dp[pi][0]
    

# 3がつかない3の倍数の個数を数える
compl = 3**(2*p-1) - 1

print(dp[p][1] + compl)
0