2010-02-24から1日間の記事一覧

Problem21

#include <iostream> #include <vector> #include <set> #include <cmath> using namespace std; #define NUM 10000 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>…

Problem20

#include <iostream> #include <string> using namespace std; #define NUM 100 void multi(string *ps, int num) { string s(""); int c = 0; for (string::size_type i = ps->size(); i > 0; i--) { int n = (ps->at(i-1)-'0') * num + c; c = n/10; s += '0' + n%10; } if (</string></iostream>…

Problem19

#include <iostream> using namespace std; #define START 1901 #define END 2000 bool isLeap(int y) { if (y%4 != 0 || (y%100 == 0 && y%400 != 0)) { return false; } else { return true; } } int main(int argc, char **argv) { int md[13] = { 0, 31, 28, 31, 3</iostream>…

Problem18

#include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; #define NUM "\ 75\n\ 95 64\n\ 17 47 82\n\ 18 35 87 10\n\ 20 04 82 47 65\n\ 19 01 23 75 03 34\n\ 88 02 77 73 07 63 67\n\ 99 65 04 28 06 16 70 92\n\ 41 41 26 56 83 40 80 70 33\n\ 4</vector></string></sstream></iostream>…