結果

問題 No.2177 Recurring ab
ユーザー square1001square1001
提出日時 2023-01-06 21:32:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 10,728 KB
実行使用メモリ 7,960 KB
最終ジャッジ日時 2023-08-20 14:34:49
合計ジャッジ時間 1,951 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
7,768 KB
testcase_01 AC 21 ms
7,960 KB
testcase_02 AC 21 ms
7,896 KB
testcase_03 AC 21 ms
7,852 KB
testcase_04 AC 20 ms
7,820 KB
testcase_05 AC 21 ms
7,900 KB
testcase_06 AC 21 ms
7,796 KB
testcase_07 AC 21 ms
7,924 KB
testcase_08 AC 21 ms
7,836 KB
testcase_09 AC 20 ms
7,796 KB
testcase_10 AC 21 ms
7,912 KB
testcase_11 AC 21 ms
7,768 KB
testcase_12 AC 21 ms
7,888 KB
testcase_13 AC 21 ms
7,900 KB
testcase_14 AC 20 ms
7,944 KB
testcase_15 AC 21 ms
7,940 KB
testcase_16 AC 21 ms
7,756 KB
testcase_17 AC 21 ms
7,828 KB
testcase_18 AC 20 ms
7,764 KB
testcase_19 AC 21 ms
7,840 KB
testcase_20 AC 21 ms
7,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# input
n = int(input())

# brute force
answer = 0
for a in range(0, 10):
	for b in range(0, 10):
		if a == b:
			continue
		# 0.ababab... = (pa+b) * (1/p^2 + 1/p^4 + ...) = (pa+b) / (p^2-1)
		l, r = max(a, b), 10 ** 27
		while r - l > 1:
			m = (l + r) // 2
			if n * (m * a + b) > m * m - 1:
				l = m
			else:
				r = m
		answer += l - max(a, b)

# output
print(answer)
0