<iostream> corporation bank <fstream> # Include # include using namespace std; int a [10] [10], n, m, sol [10] [10], ax, bx, cx, ay, by, cy, oka = 1 , OKB = 2, OKC = 3, nr, void read () {int i, j; ifstream f ("data") f >> n >> m, for (i = 1, i <= n, i + +) for (j = 1, j <= m, j + +) f >> a [i] [j] >> f >> ax bx ay >> >> >> by >> cx cy;} void fill (int i , int j, int k) {if (a [i] [j] == k) {a [i] [j] =-k, No + +, if (i == bx && j == by) OKB = 1 , if (i == && j cx == cy) OKC = 1; fill (i-1, j, k), fill (i-1, j +1, k), fill (i, j +1, k ), fill (i +1, j +1, k), fill (i +1, j, k), fill (i +1, j-1, k), fill (i, j-1, k); fill (i-1, j-1, k);}} int main () {int NRA, i, j, k, NRB, NRC, minimum = INT_MAX, read (), k = a [ax] [ay] , oka = 1; OKB = 2; OKC = 3; fill (ax, ay, k) NRA = No, No = 0 if (oka == 1 && OKB OKC == 2 && == 3) {k = a [bx] [by]; fill (bx, by, k) NRB = No, No = 0 if (OKC == 3) cout << "different objects" fill (cx, cy, a [cx] [cy]) NRC = No, if (NRA <= && NRA NRB <= NRC) cout << endl << NRA, if (NRB <= NRA NRB && <= NRC) cout << endl << NRB, if (NRC <= NRB NRC && <= NRA) cout << endl << NRC;}} GREEDY. Unfinished. We give non-zero integer n B = {b1, b2, ..., bn} and m nonzero integers a1, a2, ..., am. (M <n). Determine a subset of B that maximizes the value of the expression E = a1 * x1 + a2 * x2 + ... + xm I * <iostream> # include # include using namespace std <fstream> int n, m, b [100] , a [100]; void read () {int i; ifstream f ("data") f >> n, for (i = 1, i <= n, i + +) f >> b [i] f> > m for (i = 1, i <= m i + +) f >> corporation bank a [i];} int main () {int e = 0, i, j, Aneg [10] bneg [10], k = 0, L = 0 mm, read (), sort (A, M + a), sort (b, n + b), mm = m for (i = 1, i <= m i + +) if ( a [i] <0) {Aneg [k] = a [i], k + +;} for (i = 1, i <= n, i + +) if (b [i] <0) {bneg [l] = b [i] l + +;} for (i = 1, i <k, corporation bank i + +) for (j = i +1, j <= k, j + +) if (abs (Aneg [i])> abs (Aneg [j] )) swap (Aneg [i], Aneg [j]) for (i = 1, i <l, i + +) for (j = i +1, j <= l, j + +) if (abs (bneg [i] )> abs (bneg [j])) swap (bneg [i], bneg [j]), while (k> 0) {e = e + Aneg [k] * bneg [l], k -, l- -;} while (mm> 0) {if (a [i]> 0) {e = e + a [mm] * b [n], mm - n -;} else break;} cout << s;}
2013 (31) June (5) April (1) August (2) May (3) February (6) February (4) February (4) May (6) 2012 (71) September (8) April (9) February (2) February (2) October (3) May (15) April (2) March (13) February (8) January (9) 2011 (87) January (7) November (20) taking you love at any time! 11/30 - Greedy clasa11info Test 11/25, 11/28 11/24 - Topcoder.com 11/23 - Greedy 11/22 - Greedy 11/21 11/17 11/16 11/15 - Fill Algorithm Tiest 11/11 / 11 - Frog Photos of 2011 11/10 11/9 - Prob. 4 to 7 11/7 - checkerboard horse 11/7 - Problems Backtracking in Plan 11/4 - Labyrinth 11/3 - Backtracking in Plan 11/2 11/1 - Greedy method corporation bank October (12) February (11 ) June (2) July (7) April (3) February (10) July (7) April (8) 2010 (88) February (10) November (19) October (22 ) September (15) July (21) February (1)
2 Romanian (1) admission (1) Fill Algorithm corporation bank (5) algorithms easy (2) Lee's algorithm (1) Other (3) Anamaria corporation bank (1) binary trees (2) Architects (1) vertical throwing corporation bank (1) certified (4) BAC (14) backtracking (16) backtracking in plan (8)
No comments:
Post a Comment