#include <iostream>
#include <vector>
#include <climits>
#include <cstdlib>
#include <ctime>
#include <random>
#include <iomanip>
using namespace std;

unsigned int myConcat(unsigned int& a, unsigned int& b) {
	switch( (b >= 10000000) ? 7 : 
			(b >= 1000000) ? 6 : 
			(b >= 100000) ? 5 : 
			(b >= 10000) ? 4 : 
			(b >= 1000) ? 3 : 
			(b >= 100) ? 2 : 
			(b >= 10) ? 1 : 0 ) {
		case 1: return a*100+b; break;
    	case 2: return a*1000+b; break;
    	case 3: return a*10000+b; break;
    	case 4: return a*100000+b; break;
    	case 5: return a*1000000+b; break;
    	case 6: return a*10000000+b; break;
    	case 7: return a*100000000+b; break;
    	default: return a*10+b; break;
    	// I don't really know what to do here
    	//case 8: return a*1000*1000*1000+b; break;
    	//case 9: return a*10*1000*1000*1000+b; break;
	}
}

unsigned int uintcat (unsigned int& ms, unsigned int& ls) {
	unsigned int mult;
	for(mult=10; mult <= ls; mult *= 10) {}
	return ms * mult + ls;
}

int main() {
	default_random_engine generator;
  	uniform_int_distribution<unsigned int> distrA(0,9),distrB(0,100*1000*1000);
  	int i;
  	
  	int testCnt = 10*1000*1000;
  	time_t start_time;
	cout << setprecision(3) << fixed;
  	
  	vector<unsigned int> a(testCnt), b(testCnt);
  	for(i = 0; i < testCnt; i++)
		a[i] = distrA(generator), b[i] = distrB(generator);
	
	start_time = clock();
	for(i = 0; i < testCnt; ++i)
		myConcat(a[i], b[i]);
	cout << (clock()-start_time)/double(CLOCKS_PER_SEC) << "\n";
		
	// use separate vectors to overcome memory hashing, but data is the same
	vector<unsigned int> c(a.begin(), a.end()), d(b.begin(), b.end());
	start_time = clock();
	for(i = 0; i < testCnt; ++i)
		uintcat(c[i], d[i]);
	cout << (clock()-start_time)/double(CLOCKS_PER_SEC) << "\n";
	
	return 0;
}