Project Euler

Problem 3

篩も懐かしいねー #include <iostream> #include <cmath> using namespace std; #define NUM 600851475143 int main(int argc, char ** argv) { unsigned int size = (unsigned int)ceil(sqrt((double)NUM)); // 篩の大きさ bool *t_prime = new bool [size]; // 素数テーブル</cmath></iostream>…

Problem 2

フィボナッチさん懐かしいねー #include <iostream> #include <vector> using namespace std; #define LIMIT 4000000 int main(int argc, char **argv) { vector<int> vf; // フィボナッチ数列 vf.push_back(1); vf.push_back(2); while (1) { vector<int>::size_type e = vf.size(); vf.</int></int></vector></iostream>…

Problem 1

set を使っているのは単に使ってみたかっただけです. #include <iostream> #include <set> using namespace std; #define NUM 1000 int main(int argc, char **argv) { set<int> s; for (int i = 3; i < NUM; i+=3) { s.insert(i); } for (int i = 5; i < NUM; i+=5) { s.insert</int></set></iostream>…