Skip to content

Commit

Permalink
Merge pull request #1 from vaishnavim141003/vaishnavim141003-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
vaishnavim141003 committed Oct 22, 2023
2 parents a01717a + 37c52d5 commit 5b8a315
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions two sets2 #138
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
def divide_into_two_sets(n):
total_sum = (n * (n + 1)) // 2 # Calculate the sum of numbers from 1 to n

# If the total sum is odd, it's not possible to divide into two sets with equal sums
if total_sum % 2 != 0:
print("NO")
else:
half_sum = total_sum // 2
set1 = []
set2 = []

while n > 0:
if half_sum - n >= 0:
set1.append(n)
half_sum -= n
else:
set2.append(n)
n -= 1

print("YES")
print(len(set1))
print(" ".join(map(str, set1)))
print(len(set2))
print(" ".join(map(str, set2))

# Read input
n = int(input())
divide_into_two_sets(n)

0 comments on commit 5b8a315

Please sign in to comment.