From be8afa2a1eb7b8caaf796e3979f5625d3e7198ac Mon Sep 17 00:00:00 2001 From: URK21CS2020AKASHNAIR Date: Mon, 16 Oct 2023 19:38:11 +0530 Subject: [PATCH] Create FRACTIONAL_KNAPSACK_PROBLEM.py --- FRACTIONAL_KNAPSACK_PROBLEM.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 FRACTIONAL_KNAPSACK_PROBLEM.py diff --git a/FRACTIONAL_KNAPSACK_PROBLEM.py b/FRACTIONAL_KNAPSACK_PROBLEM.py new file mode 100644 index 0000000..0cb9104 --- /dev/null +++ b/FRACTIONAL_KNAPSACK_PROBLEM.py @@ -0,0 +1,29 @@ +n=int(input("enter the no of input")) +b=[] +w=[] +r=[] +s=int(input("enter the total weight")) +v=0 +for i in range (0,n): + a=int(input("enter the benefict")) + d=int(input("enter the weight")) + b.append(a) + w.append(d) + r.append(a/d) +for i in range (0,n): + for j in range(i,n): + if r[i]