Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a118f4a

Browse files
avinashjha11OmkarPathak
authored andcommitted
Added problems in SPOJ section. (#6)
* SPOJ Problems * SPOJ Problems * SPOJ Problems
1 parent 750ad1f commit a118f4a

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

‎CompetitiveProgramming/SPOJ/P13_AVRG.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sum=0
2+
for i in range (0,6):
3+
a=int(input())
4+
sum+=a
5+
print(sum/6)

‎CompetitiveProgramming/SPOJ/P14_MUL.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
t = int(input())
2+
while t>0:
3+
t-=1
4+
n1, n2 = map(int, raw_input().split())
5+
print n1*n2
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
def sum(x):
2+
if x < 0:
3+
return -(-x * (-x + 1) // 2)
4+
else:
5+
return x * (x + 1) // 2
6+
7+
while True:
8+
try:
9+
a, b = map(int, input().split())
10+
if a > b:
11+
a, b = b, a
12+
if b < 0:
13+
print(sum(a) - sum(b + 1))
14+
elif a <= 0:
15+
print(sum(b) + sum(a))
16+
else:
17+
print(sum(b) - sum(a - 1))
18+
except EOFError:
19+
exit(0)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /