inlineintread(){ int X = 0, w = 0; char ch = 0; while (!isdigit(ch)) { w |= ch == '-'; ch = getchar(); } while (isdigit(ch)) { X = (X << 3) + (X << 1) + (ch ^ 48); ch = getchar(); } return w ? -X : X; }
intmain(){ int n = read(); int m = read(); for (int i = 1; i <= n; i++) { a[i].l = read(); a[i].r = read(); } sort(a + 1, a + n + 1, comp()); fenwick<int>* tree = newfenwick<int>(m); int cur = 1; for (int d = 1; d <= m; d++) { while (cur <= n && a[cur].r - a[cur].l + 1 < d) { tree->add(a[cur].l, 1); tree->add(a[cur].r + 1, -1); cur++; } int ans = n - cur + 1; for (int i = d; i <= m; i += d) { ans += tree->sum(i); } cout << ans << endl; } }