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

Problem17

#include <iostream> #include <string> using namespace std; #define NUM 1000 string numlen(int n) { if (n == 1000) { return "onethousand"; } string s; char fig1[10][7] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; char</string></iostream>…

Problem16

#include <iostream> #include <string> using namespace std; #define NUM 1000 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>…

Problem15

#include <iostream> #include <cmath> using namespace std; #define NUM 20 double fctr(int n) { double r = 1; for (int i = 2; i <= n; i++) { r *= i; } return r; } int main(int argc, char argv) { double ans; ans = fctr(NUM*2) / (fctr(NUM)*fctr(NUM)); printf("</cmath></iostream>…

Problem14

#include <iostream> using namespace std; #define NUM 1000000 int main(int argc, char **argv) { bool t[NUM]; memset(t, true, NUM); int ans = -1; int max = -1; for (int i = 2; i < NUM; i++) { if (t[i] == false) { continue; } unsigned int n = i; int l </iostream>…

Problem13

#include <iostream> #include <string> #include <vector> using namespace std; /* #define NUM "\ 37107287533902102798797998220837590246510135740250\ 46376937677490009712648124896970078050417018260538\ 74324986199524741059474233309513058123726617309629\ " */ #define N</vector></string></iostream>…