Пример #1
0
int main() {
	int n;
	while ((scanf("%d",&n)==1) && (n>0)) {
		int a = 0;
		int b = 0;
		bool odd = true;
		while(n>0){
			int lsb = LSOne(n);
			if (odd) a += lsb;
			else b += lsb;
			odd = !odd;
			n -= lsb;
		}
		printf("%d %d\n",a,b);
	}
	return 0;
}
Пример #2
0
void adjust(int k, int v) {
    for(; k <= n; k += LSOne(k))
        ft[k] += v;
}
Пример #3
0
long long int rsq(long long int b) {
    long long int sum = 0; for (; b; b -= LSOne(b)) sum += ft[b];
    return sum; }
Пример #4
0
 void adjust(long long int k, long long int v) {
    for (; k < (int)2000020; k += LSOne(k)) ft[k] += v; }
Пример #5
0
 void adjust(int k, data_type v){
     for (; k < (int)ft.size(); k += LSOne(k)) ft[k] += v;
 }
Пример #6
0
 data_type rsq(int b){
     data_type sum = 0;
     for (; b; b -= LSOne(b)) sum += ft[b];
     return sum;
 }
 int rsq(int b) { int sum = 0; for (; b; b -= LSOne(b)) sum += ft[b]; return sum; } // RSQ(1, b)
 // adjusts value of the k-th element by v (v can be +ve/inc or -ve/dec)
 void adjust(int k, int v) { for (; k < (int)ft.size(); k += LSOne(k)) ft[k] += v; }
	// update value of the k-th element by v (v can be +ve/inc or -ve/dec)
	// i.e., increment or decrement kth element by a value v
	void update(int k, int v) {
		for (; k <= size; k += LSOne(k)) ft[k] += v;
	}
	// returns sum of the range [1...b]
	int sum(int b) {
		int sum = 0;
		for (; b; b -= LSOne(b)) sum += ft[b];
		return sum;
	}