Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:总算过了…… 想的太复杂了,重写了代码……In Reply To:总算过了…… 想的太复杂了,重写了代码…… Posted by:goodness at 2008-07-28 16:23:02 #include <iostream> using namespace std; const int MIDDLE = 10000; int gnWeight[25][2 * MIDDLE], gnHook[100], gnValue[100]; int nNumHooks, nNumWeights; void Init() { cin >> nNumHooks >> nNumWeights; int i; for (i = 0; i < nNumHooks; i ++) cin >> gnHook[i]; for (i = 0; i < nNumWeights; i ++) cin >> gnValue[i]; memset(gnWeight, 0, sizeof gnWeight); } void Solve() { int i, j, k; for (i = 0; i < nNumHooks; i ++) gnWeight[0][gnHook[i] * gnValue[0] + MIDDLE] = 1; for (i = 1; i < nNumWeights; i ++) for (k = 0; k < nNumHooks; k ++) for (j = 0; j < 2 * MIDDLE - gnValue[i] * gnHook[k]; j ++) gnWeight[i][j + gnHook[k] * gnValue[i]] += gnWeight[i - 1][j]; cout << gnWeight[nNumWeights - 1][MIDDLE] << endl; } int main() { Init(); Solve(); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator