/* http://projecteuler.net/
 *
 * Problem 10
 * Find the sum of all the primes below one million.
 *
 * Solution by Melkor (Filip Niksic, fniksic@gmail.com)
 *
 **/

#include <iostream>
#include <vector>

using namespace std;

vector<bool>::size_type const nmax = 1000000L;

int main() {
    vector<bool> sito(nmax+1, true);
    long long suma(0);

    sito[0] = sito[1] = false;

    for (vector<bool>::size_type i = 0; i <= nmax; ++i)
	if (sito[i]) {
	    suma += i;
	    for (vector<bool>::size_type j = i+i; j <= nmax; j += i)
		sito[j] = false;
	}

    cout << "Result: " << suma << endl;

    return 0;
}
