Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. class List {
  2. public:
  3. void append(List list) {}
  4.  
  5. int getTotalSize() { return 0; }
  6.  
  7. bool operator>(const List) { return true; }
  8. };
  9.  
  10. int main() {
  11. int b = 10;
  12. List list;
  13. unsigned long long one = 1; // zmienne uzywane do kombinacji
  14. unsigned long long null = (unsigned long long int) n; // elementow do wziecia
  15. unsigned long long onenull = one << null;
  16.  
  17. List *temp;
  18. auto *maxList = new List; // lista z najwieksza wartoscia
  19. for (unsigned long long p = 0; p < onenull; p++) {
  20. temp = new List; // nowa tymczasowa lista
  21. for (unsigned long long i = 0; i < null; i++)
  22. if (p & one << i) // sprawdza czy dodac te krawedz
  23. temp->append(list)[i]);
  24.  
  25. if (temp->getTotalSize() <= b and *temp > *maxList) { // jesli calkowity rozmiar mniejszy od pojemnosci plecaka
  26. *maxList = *temp; // i wartosc wieksza, to wyczysc i zamien
  27. }
  28. delete temp;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement