Nothing worthy to mention.Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng * * liukaipeng at gmail dot com
We can solve this problem by simulating the calculating process of multiply two numbers on the paper, yet we've already known the product. We guess the least significant digit of one number, multiply it with the other number to get a 1 of the least
Simple problem. Just count it.Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng * * liukaipeng at gmail dot com
Simply sort will do the job. Given to jobs, j1 and j2. which should be done first? Do j1 first will cause a total fine to j2 of j1.time * j2.fine and do j2 first will cause a total fine to j1 of j2.time * j1.fine.Code:/*******************************
Let the required stack to be the sorted sequence, and the original stack to be the sequence to sort. A turtle is numbered by its position in the required stack: the top is 0, the second is 1, and so on. A turtle is said in reverse order if its
I just simulate the electing process. The RT is very slow.Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng * * liukaipeng at gmail dot com
問題描述:找出最短路徑,加權的解法:典型的dp中#include<cstdio>#include<cstdlib>#include<cmath>#include<string>#include<vector>using namespace std;const int MAXHASHSIZE=10000003;const int MAXN=13;const int MAXS=30005;long long f[MAXS];const
Do what you are told to do.Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng * * liukaipeng at gmail dot com
Let P denotes the prefix, T denotes the # of lost digits. We are searching for N, that the prefix of 2^N is P. We have an inequlity of P*10^T <= 2^N < (P+1)*10^Tthus log2(P*10^T) <= log2(2^N) < log2((P+1)*10^T),which is
#include<cstdio>#include<cstdlib>#include<cmath>#include<string>#include<vector>using namespace std;const int MAXHASHSIZE=10000003;const int MAXN=13;const int MAXS=30005;long long f[MAXS];const int v[12]={0,5,10,20,50,10