Skip to content

Commit 6faf8b7

Browse files
committed
Problem 1
Solution of problem 1.
1 parent 645f8e0 commit 6faf8b7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

#1.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Enter your code here. Read input from STDIN. Print output to STDOUT
2+
import sys
3+
inputs=sys.stdin
4+
t = int(next(inputs))
5+
for i in range(t):
6+
n = int(next(inputs))
7+
three,five,both = 0,0,0
8+
if n%3 == 0:
9+
three = n/3 - 1
10+
else:
11+
three = n/3
12+
if n%5 == 0:
13+
five = n/5 - 1
14+
else:
15+
five = n/5
16+
if n%15 == 0:
17+
both = n/15 - 1
18+
else:
19+
both = n/15
20+
print 3*three*(three+1)/2 + 5*five*(five+1)/2 - 15*both*(both+1)/2

0 commit comments

Comments
 (0)