2010-03-07から1日間の記事一覧

Problem33

/* * \file problem033.cpp * \brief Project Euler - Problem33 * * \author Takushi Homma (b1006018@fun.ac.jp) */ #include <iostream> #include <vector> #include <cmath> using namespace std; #define LMT 100 bool isNontrivial(int e, int d, int *pe, int *pd) { if (d%10 </cmath></vector></iostream>…

Problem32

/* * \file problem032.cpp * \brief Project Euler - Probmel32 * * \author Takushi Homma (b1006018@fun.ac.jp) */ #include <iostream> #include <string> #include <algorithm> #include <set> using namespace std; int main(int argc, char **argv) { int ans = 0; set<int> set_ans; string </int></set></algorithm></string></iostream>…

Problem31

/* * \file problem031.cpp * \brief Projece Euler - Problem31 * * \author Takushi Homma (b1006018@fun.ac.jp) */ #include <iostream> using namespace std; #define LMT 200 int main(int argc, char **argv) { int coins[8] = {1, 2, 5, 10, 20, 50, 100, 200};</iostream>…

Problem30

/* * \file problem030.cpp * \brief Project Euler - Problem30 * * \author Takushi Homma (b1006018@fun.ac.jp) * \date 2010/03/07 16:13:33 */ #define FIG 5 int pow5(int n) { return n*n*n*n*n; } #include <iostream> using namespace std; int main(int argc</iostream>…

Problem29

/* * \file problem029.cpp * \brief Project Euler - Problem 29 * * \author Takushi Homma (b1006018@fun.ac.jp) * \date 2010/03/01 18:40:13 */ #include <iostream> #include <cmath> #include <set> using namespace std; #define MIN 2 #define MAX 100 int main(int argc,</set></cmath></iostream>…

Problem28

/* * \file problem028.cpp * \brief うずまき * * \author Takushi Homma (b1006018@fun.ac.jp) * \date 2010/03/01 18:40:13 */ #include <iostream> using namespace std; #define LEN 1001 int main(int argc, char **argv) { int ans = 1; int ru = 1; for (int l</iostream>…

Problem27

#include <iostream> #include <cmath> using namespace std; #define TLEN 2001000 #define LMTAB 1000 #define LMTN 10 // 素数テーブルの作成 void primeTable(bool t_prime[]) { unsigned int size = (unsigned int)ceil(sqrt((double)TLEN)); // 篩の大きさ // 篩にかけ</cmath></iostream>…

Problem26

#include <iostream> #include <vector> #include <utility> using namespace std; #define NUM 1000 typedef struct { int e; int d; } frac; bool isBreak(vector<frac> *pv, frac *fc) { bool f = false; for (vector<frac>::iterator it = pv->begin(), end = pv->end(); it != end; it++) { if </frac></frac></utility></vector></iostream>…

Problem25

#include <iostream> #include <string> using namespace std; #define NUM 1000 string reverse(string *s) { string t; t.resize(s->size()); for (string::size_type i = 0, e = s->size(); i < e; i++) { t.at(i) = s->at(e-i-1); } return t; } string sum(string *psrc, </string></iostream>…

Problem24

#include <iostream> #include <string> #include <algorithm> using namespace std; #define NUM 1000000 int main(int argc, char **argv) { string s = "0123456789"; for (int i = 1; i < NUM; i++) { next_permutation(s.begin(), s.end()); } cout << s << endl; return 0; }</algorithm></string></iostream>

Problem23

#include <iostream> #include <vector> #include <set> #include <cmath> using namespace std; #define LIMIT 28123 void aliquot(int n, set<int> *pset_pf) { pset_pf->insert(1); if(n == 2) { return; } bool *t = new bool [n]; memset(t, false, n); t[1] = true; for (int i = 2; i < n</int></cmath></set></vector></iostream>…

Problem22

#include <iostream> #include <fstream> #include <set> #include <string> using namespace std; void split(char *token, const char *delimit, set<string> *pv) { char *tk; tk = strtok(token, delimit); while (tk != NULL) { pv->insert(tk); tk = strtok(NULL, delimit); } } void split(str</string></string></set></fstream></iostream>…