Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- class Task4:
- def __init__(self):
- self.data = []
- self.pages = 0
- self.bent_pages = 0
- self.pages_sum = 0
- self.pages_temp_sum = 0
- def write_in_data(self):
- file = open('book.in')
- self.data = [i.split('\n')[0] for i in file.readlines()]
- self.pages = int(self.data[0].split()[0])
- self.bent_pages = int(self.data[0].split()[1])
- self.data.pop(0)
- self.data = [int(i) for i in self.data]
- if 1 <= self.bent_pages <= 10 ** 4:
- pass
- else:
- sys.exit(0)
- def main(self):
- self.write_in_data()
- temp_arr = []
- for i in range(self.pages, 1, -1):
- temp_arr.append(i)
- for j in range(len(temp_arr), 0, -1):
- for d in self.data:
- if j == d:
- temp_arr.pop(j)
- for l in temp_arr:
- self.pages_sum += l
- for i in self.data:
- self.pages_temp_sum += self.bent_pages * i
- self.write_in_file()
- def write_in_file(self):
- file = open('book.out', 'w')
- file.write(str(self.pages_sum - self.pages_temp_sum))
- obj = Task4()
- obj.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement