Skip to content

Instantly share code, notes, and snippets.

@BayronVazquez
Created August 12, 2022 02:27
Show Gist options
  • Save BayronVazquez/a952f5d4d6af4d1c885b57036c98d9c7 to your computer and use it in GitHub Desktop.
Save BayronVazquez/a952f5d4d6af4d1c885b57036c98d9c7 to your computer and use it in GitHub Desktop.

Goal

In class, Roo goes up to the whiteboard and draws a circle. On the circle, he plots N points. His friend Voo wants to connect all the points with lines, but the marker is running out of ink and he doesn't know if he can! The marker has i millilitres of ink remaining and drawing each line takes x amount of ink out of the marker. If he can connect all the points, print "yes" and how much ink he used. If not, print "no" and how much more ink he needs to draw all the lines. Remember that each point on the circle must be connected to every other point (don't over count though!!!) Source: (https://www.codingame.com)[https://www.codingame.com]

Input

An int N which represents the number of points on the circle, an int i which represents the number of millilitres of ink in the marker, and an int x of millilitres of ink it takes to draw each line.

Output

If he drew all the lines, the statement "yes" followed by how much ink he used. Otherwise, the statement "no" followed by how much more ink he needed to draw all the lines.

Constraints

1 < N < 10^5 1 < x < i < 10^5

Cases

Input 1: Small test

4
10
5

Output 1

no
20

Input 2: A few more points

15
40
3

Output 2

no
275

Input 3: Huge marker

20
1000
18

Output 3

no
2420

Input 4: Bigger is better

100
99999
7

Output 4

yes
34650
import sys
import math
n = int(input())
i = int(input())
x = int(input())
a = n*(n-1)//2*x
if a <= i:
print('yes')
print(a)
else:
print('no')
print(a-i)
import sys
import math
n = int(input())
i = int(input())
x = int(input())
r=sum(range(n))*x-i
if r>0:
print('no')
print(r)
else:
print('yes')
print(sum(range(n))*x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment