This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 1e6: 0.036s | |
* 1e7: 0.291s | |
* 1e8: 3.358s | |
* 1e9: 49.636s | |
*/ | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Project Euler - Problem 358 | |
*/ | |
#include <stdio.h> | |
#include <inttypes.h> | |
int main(void) | |
{ | |
const uint32_t p = 729809891; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdbool.h> | |
#include <inttypes.h> | |
#include <math.h> | |
bool is_prime(uint64_t x) | |
{ | |
for (uint32_t i = 2, root = sqrt(x); i <= root; i++) { | |
if (x % i == 0) return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Project Euler - Problem 417 | |
*/ | |
#include <iostream> | |
#include <algorithm> | |
#include <vector> | |
#include <cmath> | |
#include <cinttypes> | |
#include <omp.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Project Euler - Problem 437 (Brute forcing) | |
*/ | |
#include <iostream> | |
#include <vector> | |
#include <cmath> | |
#include <cinttypes> | |
#include <omp.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* N = 1e4 => 0.049s | |
* N = 1e5 => 3.890s | |
*/ | |
#include <iostream> | |
#include <cinttypes> | |
#include <omp.h> | |
const uint32_t N = 1e5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Project Euler - Problem 433 | |
* A parallelized brute force approach. | |
* | |
* N = 1e4 => 0.030s | |
* N = 1e5 => 1.941s | |
* N = 1e6 => 196.731s | 3m16.731s | |
* N = 5e6 => 4987.348s | 83m07.348s | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Project Euler - Problem 229 | |
* A simple brute force approach. | |
*/ | |
#include <iostream> | |
#include <vector> | |
#include <cinttypes> | |
uint64_t solve(uint64_t N) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cinttypes> | |
const uint32_t N = 5e6; | |
uint64_t coefs[N+1]; | |
void solve(uint32_t a, uint32_t b) | |
{ | |
static uint32_t e = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* N = 1e2 => 0.002s | |
* N = 1e3 => 0.006s | |
* N = 1e4 => 0.138s | |
* N = 1e5 => 14.350s | |
*/ | |
#include <iostream> | |
#include <cinttypes> |