結果
問題 |
No.864 四方演算
|
ユーザー |
![]() |
提出日時 | 2025-03-20 18:45:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 55 ms / 1,000 ms |
コード長 | 1,071 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 82,940 KB |
実行使用メモリ | 62,936 KB |
最終ジャッジ日時 | 2025-03-20 18:45:45 |
合計ジャッジ時間 | 2,458 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
import math def main(): import sys input = sys.stdin.read().split() N = int(input[0]) K = int(input[1]) res = 0 max_i = int(math.isqrt(K)) for i in range(1, max_i + 1): if K % i != 0: continue j = K // i candidates = [i, j] if i != j else [i] for s in candidates: if s < 2 or s > 2 * N: continue t = K // s if t < 2 or t > 2 * N: continue # Calculate count for s = a + c low_s = max(1, s - N) high_s = min(s - 1, N) cnt_s = 0 if low_s <= high_s: cnt_s = high_s - low_s + 1 # Calculate count for t = b + d low_t = max(1, t - N) high_t = min(t - 1, N) cnt_t = 0 if low_t <= high_t: cnt_t = high_t - low_t + 1 res += cnt_s * cnt_t print(res) if __name__ == '__main__': main()