結果

問題 No.294 SuperFizzBuzz
ユーザー parukiparuki
提出日時 2016-07-09 15:33:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 87 ms / 5,000 ms
コード長 766 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-21 10:43:20
合計ジャッジ時間 2,059 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
11,008 KB
testcase_01 AC 74 ms
11,008 KB
testcase_02 AC 83 ms
11,008 KB
testcase_03 AC 70 ms
10,880 KB
testcase_04 AC 68 ms
10,880 KB
testcase_05 AC 69 ms
11,008 KB
testcase_06 AC 70 ms
11,008 KB
testcase_07 AC 75 ms
11,008 KB
testcase_08 AC 80 ms
10,880 KB
testcase_09 AC 80 ms
11,008 KB
testcase_10 AC 80 ms
11,008 KB
testcase_11 AC 84 ms
10,880 KB
testcase_12 AC 81 ms
10,880 KB
testcase_13 AC 87 ms
11,008 KB
testcase_14 AC 85 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc(x):
	dp = [[[[0 for l in range(2)] for k in range(2)] for j in range(15)] for i in range(30)]
	s = str(x)
	v = [int(c) for c in s]
	dp[0][0][0][0] = 1
	for i in range(len(v)):
		for md15 in range(15):
			for notZero in range(2):
				for les in range(2):
					val = dp[i][md15][notZero][les]
					if val==0:
						continue
					for d in [3, 5]:
						nmd15 = (md15*10+d)%15
						if les==0 and d > v[i]:
							continue
						nles = les
						if d < v[i]:
							nles = 1
						dp[i+1][nmd15][1][nles] += val
					if notZero==0:
						dp[i+1][0][0][1] += val
	return dp[len(v)][0][1][0]+dp[len(v)][0][1][1]

N = int(input())

# (l, r]
l, r, m = 0, 5533533555333355355553555, 0
while r-l>1:
	m = (l+r)//2
	y = calc(m)
	if y>=N:
		r = m
	else:
		l = m
print(r)
0