提交时间:2020-11-16 10:54:51
运行 ID: 1825
#include<bits/stdc++.h> #define int long long using namespace std; const int N=1e6+10; int n,m,ans; int L[N],R[N]; signed main() { scanf("%lld%lld",&n,&m); for(int i=1;i<=m;i++) scanf("%d%d",&L[i],&R[i]); for(int B=1;B<=n;B++) { ans=0; for(int i=1;i<=m;i++) { int l=L[i],r=R[i]; if((l-1)/B+1==(r-1)/B+1) ans+=(r-l+1); else ans+=B+(r-1)-(r-1)/B*(B-1)-(l-1)+(l-1)/B*(B-1); } printf("%lld ",ans); } return 0; }