結果
問題 | No.2359 A in S ? |
ユーザー |
![]() |
提出日時 | 2023-06-23 22:23:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 453 ms / 2,000 ms |
コード長 | 925 bytes |
コンパイル時間 | 4,187 ms |
コンパイル使用メモリ | 250,664 KB |
最終ジャッジ日時 | 2025-02-15 01:14:38 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <stdio.h>#include <atcoder/all>#include <bits/stdc++.h>using namespace std;using namespace atcoder;using mint = modint998244353;#define rep(i,n) for (int i = 0; i < (n); ++i)#define Inf32 1000000001#define Inf64 4000000000000000001int main(){int B = 400;int N,M;cin>>N>>M;vector<int> l(N),rr(N),m(N),r(N);rep(i,N){cin>>l[i]>>rr[i]>>m[i]>>r[i];}vector<int> C(100005);rep(i,N){if(m[i]>=B){for(int j= r[i];j<C.size();j+=m[i]){if(j>=l[i]&&j<=rr[i])C[j]++;}}}for(int i=1;i<B;i++){vector<int> c(100005);rep(j,N){if(i==m[j]){rr[j]++;while((rr[j]-r[j])%i!=0)rr[j]++;while((l[j]-r[j])%i!=0)l[j]++;if(rr[j]<c.size())c[rr[j]]--;if(l[j]<c.size())c[l[j]]++;}}rep(j,c.size()){if(j+i<c.size())c[j+i] += c[j];}rep(j,c.size())C[j] += c[j];}rep(i,M){int a;cin>>a;cout<<C[a]<<endl;}return 0;}