For the following mass-insert, because the inputs are ordered, are there any (slight) optimizations?
set<int> primes;
for ( int i = 2; i <= 2000000; i++ ) {
primes.insert(i);
}
// then follows Sieve of Eratosthenes algorithm
New improvement, twice as fast:
set<int> primes;
for ( int i = 2; i <= 2000000; i++ ) {
primes.insert(primes.end(), i);
}
// then follows Sieve of Eratosthenes algorithm