#include using namespace std; #define INF 100000000 #define YJ 1145141919 #define INF_INT_MAX 2147483647 #define INF_LL 9223372036854775 #define INF_LL_MAX 9223372036854775807 #define EPS 1e-10 #define MOD 1000000007 #define Pi acos(-1) #define LL long long #define ULL unsigned long long #define LD long double #define int long long #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(a) begin((a)), end((a)) #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) int P; int Q; struct Node { int l, r; int p; int lValue, rValue; int sumValue; Node() { l = 1145141919; r = 0; p = lValue = rValue = sumValue = 0; } bool operator < (const Node& n) const { return l < n.l; } void debugPrint() { fprintf(stderr, "l:%d, r:%d, p:%d, lValue:%d rValue:%d sumValue:%d\n", l, r, p, lValue, rValue, sumValue); } }; vector vec; class SegmentTree{ public: SegmentTree(int size) { init(size); } void init(int size) { vec.clear(); k = 1; while(k < size) { k *= 2; } REP(i,2*k) { vec.push_back(Node()); } lastPos = k-1; } void set(int i, Node node) { i += k-1; vec[i] = node; while(i > 0) { i = (i-1)/2; Node& n = vec[i]; Node& l = vec[i*2+1]; Node& r = vec[i*2+2]; n.l = min(n.l, min(l.l, r.l)); n.r = max(n.r, max(l.r, r.r)); n.sumValue = l.sumValue + r.sumValue; } } int find(int l, int r, int pos = 0) { Node& n = vec[pos]; int x = n.l; int y = n.r; // cerr << pos << ": " << x << " " << y << " " << l << " " << r << endl; // cerr << "bool: " << (r < x || y < l) << endl; if(r < x || y < l) { // cerr << "0!!!" << endl; return 0; } if(lastPos <= pos) { int ll = max(l,x); int rr = min(r,y); int llValue = n.lValue - n.p*(ll-n.l); int rrValue = n.lValue - n.p*(rr-n.l); return (llValue+rrValue)*(rr-ll+1)/2; } else { if(l <= x && y <= r) { return vec[pos].sumValue; } else { return find(l,r,2*pos+1) + find(l,r,2*pos+2); } } } vector vec; int k; int lastPos; }; signed main() { cin >> P >> Q; int r = P; int l = 1; while(l<=r) { Node lNode; lNode.l = lNode.r = lNode.p = l; lNode.rValue = lNode.lValue = lNode.sumValue = P%l; vec.push_back(lNode); if(!(l> l >> r; if(P < l) { cout << P*(r-l+1) << endl; } else if(P < r) { cout << P*(r-P) + segTree.find(l,P) << endl; } else { cout << segTree.find(l,r) << endl; } } return 0; }