結果

問題 No.2177 Recurring ab
ユーザー MasKoaTSMasKoaTS
提出日時 2022-11-16 20:37:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 82,912 KB
最終ジャッジ日時 2023-10-17 18:11:48
合計ジャッジ時間 7,300 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 260 ms
82,200 KB
testcase_01 AC 129 ms
80,820 KB
testcase_02 AC 277 ms
82,244 KB
testcase_03 AC 267 ms
82,484 KB
testcase_04 AC 280 ms
82,636 KB
testcase_05 AC 278 ms
82,256 KB
testcase_06 AC 279 ms
82,800 KB
testcase_07 AC 281 ms
82,812 KB
testcase_08 AC 276 ms
82,560 KB
testcase_09 AC 276 ms
82,872 KB
testcase_10 AC 274 ms
82,820 KB
testcase_11 AC 278 ms
82,332 KB
testcase_12 AC 268 ms
82,540 KB
testcase_13 AC 276 ms
82,812 KB
testcase_14 AC 264 ms
82,800 KB
testcase_15 AC 273 ms
82,912 KB
testcase_16 AC 274 ms
82,244 KB
testcase_17 AC 270 ms
82,560 KB
testcase_18 AC 268 ms
82,312 KB
testcase_19 AC 273 ms
82,816 KB
testcase_20 AC 271 ms
82,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# AC(?)

import sys
from decimal import Decimal as dec
from itertools import permutations
input = sys.stdin.readline

n = int(input())

def check(p, a, b):
	return dec(p * a + b) / dec(p ** 2 - 1) > dec(1) / dec(n)

ans = 0
for a, b in permutations([*range(10)], 2):
	min_p = max(a, b) + 1
	if not(check(min_p, a, b)):
		continue
	ok = min_p
	ng = 10 ** 9 + 1
	while(ng - ok > 1):
		p = (ok + ng) >> 1
		if(check(p, a, b)):
			ok = p
		else:
			ng = p
	ans += ok - min_p + 1

print(ans)
0