結果

問題 No.2177 Recurring ab
ユーザー MasKoaTSMasKoaTS
提出日時 2022-11-16 20:40:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 89,340 KB
最終ジャッジ日時 2023-10-17 18:11:54
合計ジャッジ時間 5,478 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 190 ms
89,048 KB
testcase_01 AC 144 ms
87,756 KB
testcase_02 AC 202 ms
89,080 KB
testcase_03 AC 195 ms
89,076 KB
testcase_04 AC 196 ms
89,076 KB
testcase_05 AC 204 ms
89,096 KB
testcase_06 AC 202 ms
89,080 KB
testcase_07 AC 196 ms
89,064 KB
testcase_08 AC 200 ms
89,080 KB
testcase_09 AC 204 ms
89,340 KB
testcase_10 AC 202 ms
89,068 KB
testcase_11 AC 198 ms
89,072 KB
testcase_12 AC 217 ms
89,084 KB
testcase_13 AC 200 ms
89,096 KB
testcase_14 AC 201 ms
89,072 KB
testcase_15 AC 204 ms
89,100 KB
testcase_16 AC 198 ms
89,072 KB
testcase_17 AC 198 ms
89,076 KB
testcase_18 AC 198 ms
89,064 KB
testcase_19 AC 200 ms
89,080 KB
testcase_20 AC 200 ms
89,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# AC(?)

import sys
from fractions import Fraction as frac
from itertools import permutations
input = sys.stdin.readline

n = int(input())

def check(p, a, b):
	return frac(p * a + b) / frac(p ** 2 - 1) > frac(1) / frac(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