結果

問題 No.2177 Recurring ab
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-01-06 22:47:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 790 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 76,556 KB
最終ジャッジ日時 2023-08-20 16:09:19
合計ジャッジ時間 6,220 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 168 ms
76,192 KB
testcase_01 AC 151 ms
75,868 KB
testcase_02 AC 81 ms
76,132 KB
testcase_03 AC 169 ms
76,148 KB
testcase_04 AC 167 ms
76,020 KB
testcase_05 AC 167 ms
76,208 KB
testcase_06 AC 170 ms
75,992 KB
testcase_07 AC 170 ms
76,152 KB
testcase_08 AC 80 ms
76,044 KB
testcase_09 AC 83 ms
76,136 KB
testcase_10 AC 84 ms
75,960 KB
testcase_11 AC 171 ms
76,108 KB
testcase_12 AC 85 ms
76,556 KB
testcase_13 AC 173 ms
76,064 KB
testcase_14 AC 83 ms
76,116 KB
testcase_15 AC 83 ms
76,064 KB
testcase_16 AC 169 ms
75,892 KB
testcase_17 AC 260 ms
76,020 KB
testcase_18 AC 83 ms
76,240 KB
testcase_19 AC 83 ms
75,928 KB
testcase_20 AC 84 ms
76,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

# x = (p*a+b)/(p**2-1) > 1/n
# (p*a+b)*n > p**2-1
# 0 > p**2 - p*a*n -1 - b*n
# 0 > (p-a*n/2)**2 -1 - b*n - (a*n/2)**2
M = 10**9+1
def f(p,a,b):
    return p**2-p*a*n-1-b*n < 0
ans = 0


for a in range(10):
    for b in range(10):
        if a == b:
            continue

        if n >= 10**4:
            for p in range(max(a,b)+1,100):
                if f(p,a,b):
                    ans += 1

            ll = 100
            l = ll
            r = M
            while l+1 < r:
                m = (r+l)//2
                if f(m,a,b):
                    l = m
                else:
                    r = m
            ans += l-ll+1
        else:
            for p in range(max(a,b)+1,2*10**5):
                if f(p,a,b):
                    ans += 1

print(ans)
0