예제 #1
0
int main() {
	long long lower, upper;
	while ((scanf("%lld %lld",&lower,&upper)==2) && (lower>=0 && upper>=0)) {
		printf("%lld\n",sumF(upper)-sumF(lower-1));
	}
	return 0;
}
예제 #2
0
		/* Sum contributions from all threads, save to _force&_torque.
		 * Locks globalMutex, since one thread modifies common data (_force&_torque).
		 * Must be called before get* methods are used. Exception is thrown otherwise, since data are not consistent. */
		inline void sync(){
			for(int i=0; i<nThreads; i++){
				if (_maxId[i] > 0) { synced = false;}
			}
			if(synced) return;
			boost::mutex::scoped_lock lock(globalMutex);
			if(synced) return; // if synced meanwhile
			
			for(int i=0; i<nThreads; i++){
				if (_maxId[i] > 0) { ensureSize(_maxId[i],i);}
			}
			
			syncSizesOfContainers();

			for(long id=0; id<(long)size; id++){
				Vector3r sumF(Vector3r::Zero()), sumT(Vector3r::Zero());
				for(int thread=0; thread<nThreads; thread++){ sumF+=_forceData[thread][id]; sumT+=_torqueData[thread][id];}
				_force[id]=sumF; _torque[id]=sumT;
				if (permForceUsed) {_force[id]+=_permForce[id]; _torque[id]+=_permTorque[id];}
			}
			if(moveRotUsed){
				for(long id=0; id<(long)size; id++){
					Vector3r sumM(Vector3r::Zero()), sumR(Vector3r::Zero());
					for(int thread=0; thread<nThreads; thread++){ sumM+=_moveData[thread][id]; sumR+=_rotData[thread][id];}
					_move[id]=sumM; _rot[id]=sumR;
				}
			}
			synced=true; syncCount++;
		}
예제 #3
0
long long sumF(long long x){
	if(x==0) return 0;
	else if(x<10) return summation(x);
	else return sumF(x/10)+(x/10*45)+summation(x%10);
}