- 博客(17)
- 资源 (1)
- 收藏
- 关注
原创 110508 Pairsumonious Numbers
#include #include #include #include using namespace std;static int FindNumber(const vector& src, int target, int start, int end){ if (end < start) return -1; int mid = (start + end) / 2;
2013-10-29 14:48:18 575
原创 110507 The Stern-Brocot Number System
#include using namespace std;class SternBrocotNo{public: SternBrocotNo(int x, int y) : m_x(x), m_y(y) {} SternBrocotNo(const SternBrocotNo& other) : m_x(other.m_x), m_y(other.m_y) {} bool o
2013-10-28 13:05:36 450
原创 110506 Polynomial coefficients
#include using namespace std;static int C(int n, int k){ if (k == 0) return 1; int a = 1, b = 1; for (int i = 1; i <= k; ++i) { b *= i; a *= n; --n; } return a / b;}static int
2013-10-28 11:33:17 604
原创 110505 A multiplication game
This solution gets "Wrong answer" result inhttp://www.programming-challenges.com/,but it gets "Accepted" result inhttp://uva.onlinejudge.org/.I don't know why so far.#include #include
2013-10-25 17:43:10 586
原创 110504 Ones
#include #include using namespace std;static int s_Multiplier[] = {0, 1, 0, 7, 0, 0, 0, 3, 0, 9};static void Multiply(int src, int multiplier, int& result, int& flag){ result = src * multipli
2013-10-24 13:30:15 564
原创 110503 The Archeologists' Dilemma
// Suppose the given number is X, then// X*(10^Y) Y*log10 + logX < N < Y*log10 + log(X+1)// Another limitation is: Y > int(lgX) + 1#include #include using namespace std;static int SmallestIn
2013-10-24 11:04:38 598
原创 110502 Reverse and Add
#include #include #include #include #include using namespace std;static bool IsReverse(const char* num, int len){ int mid = len / 2; for (int i = 0; i < mid; ++i) { if (num[i] != num[len
2013-10-18 13:59:45 748
原创 110501 Primary Arithmetic
#include #include using namespace std;#define BUF_SIZE 1024static bool Add(const char& ch1, const char& ch2, bool currentFlag){ int num1 = ch1 - '0'; int num2 = ch2 - '0'; int flag = curren
2013-10-18 12:29:08 761
原创 110408 Football (aka Soccer)
This solution gets "Wrong answer" result inhttp://www.programming-challenges.com/,but it gets "Accepted" result inhttp://uva.onlinejudge.org/.I don't know why so far.#include #include
2013-10-17 12:16:26 595
原创 110407 ShellSort
This solution gets "Wrong answer" result inhttp://www.programming-challenges.com/,but it gets "Accepted" result inhttp://uva.onlinejudge.org/.According to the explanation in http://www.program
2013-10-16 13:22:51 575
原创 110406 CDVII
#include #include #include #include #include #include #include #include #include #include using namespace std;const int HOURS_IN_DAY = 24;const int MINUTE_IN_HOUR = 60;const int PASS_
2013-10-15 16:49:04 566
原创 110405 Shoemaker's Problem
#include using namespace std;class ShoeMaker{public: void Init(int index, int days, int punishment) { m_index = index; m_days = days; m_punishment = punishment; } class Comparer { p
2013-10-15 12:06:47 505
原创 110404 Longest Nap
#include #include #include #include using namespace std;#define TIME_UNIT 60static const int START_TIME = 10 * TIME_UNIT;static const int END_TIME = 18 * TIME_UNIT;class Interval{public:
2013-10-14 17:02:31 613
原创 110403 Bridge
#include #include using namespace std;template static void Swap(T* data, int index1, int index2){ if (index1 == index2) return; T temp = *(data + index1); *(data + index1) = *(data + inde
2013-10-14 11:46:59 547
原创 110402 Stacks of Flapjacks
#include #include #include #include using namespace std;static void GetVecFromStr(vector& data, char* str){ int i = 0; int firstDigit = -1; while(true) { if ((str[i] >= '0') && (str[i] <
2013-10-12 15:34:59 438
原创 110401 Vito's Family
#include #include using namespace std;#define ABS(x) (((x) < 0) ? -(x) : (x))template static void Swap(T* data, int x, int y){ if (x == y) return; T temp = *(data + x); *(data + x) = *(
2013-10-11 13:41:15 572
原创 110308 Fmt
#include #include #include #include #include using namespace std;enum CharType_t{ SPACE, NEWLINE, NORMAL};struct StrInfo{ StrInfo(char* str, int len, CharType_t charType) : m_len(l
2013-10-10 17:01:00 387
c++语言的设计和演化
2009-07-22
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人