結果
問題 |
No.781 円周上の格子点の数え上げ
|
ユーザー |
![]() |
提出日時 | 2025-03-31 17:32:22 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,326 bytes |
コンパイル時間 | 178 ms |
コンパイル使用メモリ | 82,836 KB |
実行使用メモリ | 147,356 KB |
最終ジャッジ日時 | 2025-03-31 17:33:24 |
合計ジャッジ時間 | 8,065 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 TLE * 1 |
ソースコード
import sys import array def main(): X, Y = map(int, sys.stdin.readline().split()) if X == 0: X = 1 # According to problem statement, X >=1 # Sieve of smallest prime factors up to Y max_R = Y spf = array.array('I', (i for i in range(max_R + 1))) for i in range(2, int(max_R**0.5) + 1): if spf[i] == i: # i is a prime for j in range(i * i, max_R + 1, i): if spf[j] == j: spf[j] = i max_f = 0 for R in range(X, Y + 1): current = R valid = True product = 1 while current > 1: p = spf[current] if p % 4 == 3: count_p = 0 while current % p == 0: count_p += 1 current = current // p if count_p % 2 != 0: valid = False break else: count_p = 0 while current % p == 0: count_p += 1 current = current // p if p != 2: product *= (count_p + 1) if valid: current_f = 4 * product if current_f > max_f: max_f = current_f print(max_f) if __name__ == '__main__': main()