結果
問題 |
No.2359 A in S ?
|
ユーザー |
![]() |
提出日時 | 2025-06-12 20:04:35 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,088 bytes |
コンパイル時間 | 184 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 139,508 KB |
最終ジャッジ日時 | 2025-06-12 20:10:12 |
合計ジャッジ時間 | 4,195 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 2 TLE * 1 -- * 15 |
ソースコード
import sys def main(): input = sys.stdin.read data = input().split() idx = 0 N = int(data[idx]) M = int(data[idx+1]) idx += 2 max_A = 10**5 freq = [0] * (max_A + 1) for _ in range(N): L = int(data[idx]) R = int(data[idx+1]) X = int(data[idx+2]) Y = int(data[idx+3]) idx += 4 if X == 0: continue a_start = Y while a_start < L: a_start += X if a_start > R: continue a_end = Y quotient = (R - Y) // X a_end = Y + quotient * X if a_end < a_start: continue k = 0 current = a_start while current <= a_end and current <= max_A: if current >= L and current <= R: if current <= max_A: freq[current] += 1 current += X queries = list(map(int, data[idx:idx+M])) for A in queries: print(freq[A]) if __name__ == '__main__': main()