結果
問題 |
No.781 円周上の格子点の数え上げ
|
ユーザー |
![]() |
提出日時 | 2025-03-20 18:44:09 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,978 ms / 2,000 ms |
コード長 | 1,049 bytes |
コンパイル時間 | 165 ms |
コンパイル使用メモリ | 82,852 KB |
実行使用メモリ | 154,860 KB |
最終ジャッジ日時 | 2025-03-20 18:44:19 |
合計ジャッジ時間 | 7,683 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
def sieve(n): spf = list(range(n + 1)) for i in range(2, int(n**0.5) + 1): if spf[i] == i: # i is a prime for j in range(i * i, n + 1, i): if spf[j] == j: spf[j] = i return spf def main(): import sys X, Y = map(int, sys.stdin.readline().split()) max_f = 0 spf = sieve(Y) for R in range(X, Y + 1): current_R = R valid = True product = 1 p_count = {} while current_R > 1: p = spf[current_R] count = 0 while current_R % p == 0: count += 1 current_R //= p if p % 4 == 3: if count % 2 != 0: valid = False break elif p % 4 == 1: product *= (count + 1) if valid: current_f = 4 * product else: current_f = 0 if current_f > max_f: max_f = current_f print(max_f) if __name__ == '__main__': main()