結果
| 問題 |
No.2177 Recurring ab
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 20:25:08 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 2,000 ms |
| コード長 | 1,097 bytes |
| コンパイル時間 | 180 ms |
| コンパイル使用メモリ | 82,708 KB |
| 実行使用メモリ | 60,376 KB |
| 最終ジャッジ日時 | 2025-03-20 20:26:34 |
| 合計ジャッジ時間 | 2,003 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
def main():
import sys
input = sys.stdin.read().split()
N = int(input[0])
total = 0
# Case 2: p from 2 to 9
for p in range(2, 10):
required = p * p - 1
count = 0
for a in range(p):
for b in range(p):
if a == b:
continue
if (p * a + b) * N > required:
count += 1
total += count
# Case 1: p >= 10, a and b from 0-9, a != b
for a in range(10):
for b in range(10):
if a == b:
continue
Na = N * a
Nb = N * b + 1
low = 10
high = 10**9
best = 0
while low <= high:
mid = (low + high) // 2
lhs = mid * mid
rhs = Na * mid + Nb
if lhs < rhs:
best = mid
low = mid + 1
else:
high = mid - 1
if best >= 10:
total += best - 10 + 1
print(total)
if __name__ == "__main__":
main()
lam6er