| Task: | Loops |
| Sender: | OuuGiii |
| Submission time: | 2018-09-12 15:12:17 +0300 |
| Language: | Python3 |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | details |
| #2 | ACCEPTED | 0.05 s | details |
| #3 | ACCEPTED | 0.05 s | details |
| #4 | ACCEPTED | 0.03 s | details |
| #5 | ACCEPTED | 0.05 s | details |
| #6 | RUNTIME ERROR | 0.05 s | details |
| #7 | RUNTIME ERROR | 0.04 s | details |
| #8 | RUNTIME ERROR | 0.05 s | details |
| #9 | RUNTIME ERROR | 0.05 s | details |
| #10 | RUNTIME ERROR | 0.05 s | details |
| #11 | RUNTIME ERROR | 0.04 s | details |
| #12 | RUNTIME ERROR | 0.05 s | details |
| #13 | RUNTIME ERROR | 0.04 s | details |
| #14 | RUNTIME ERROR | 0.06 s | details |
| #15 | RUNTIME ERROR | 0.05 s | details |
| #16 | RUNTIME ERROR | 0.05 s | details |
| #17 | RUNTIME ERROR | 0.05 s | details |
| #18 | RUNTIME ERROR | 0.05 s | details |
| #19 | RUNTIME ERROR | 0.04 s | details |
| #20 | RUNTIME ERROR | 0.05 s | details |
Code
def solve1(n):
x = 0;
for a in range(n, 0, -1):
for b in range(1, a+1):
x += b
# print(x)
return x;
def solve2(n):
x = 0;
for a in range(n-2, 0, -1):
for b in range(1, a+1):
x += b
# print(x)
return x + (n*n);
# Best Solution
def solve3(n):
x = 0
for a in range(n, 0, -2):
x += a*a
return x;
# Recursive Solution
def solve4(n):
if (n > 0):
return n*n + solve4(n-2)
return 0
def main():
number = input()
if (0 <= int(number) <= 1000000):
print(solve4(int(number)))
main()
# Solve(5)
# 1+2+3+4+5 = 15
# 1+2+3+4 = 10
# 1+2+3 = 6
# 1+2 = 3
# 1 = 1
# --
# 35
# Solve3(5)
# 5*5 = 25
# 3*3 = 9
# 1*1 = 1
# --
# 35Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 1 |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 2 |
| correct output |
|---|
| 4 |
| user output |
|---|
| 4 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 3 |
| correct output |
|---|
| 10 |
| user output |
|---|
| 10 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 4 |
| correct output |
|---|
| 20 |
| user output |
|---|
| 20 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 5 |
| correct output |
|---|
| 35 |
| user output |
|---|
| 35 |
Test 6
Verdict: RUNTIME ERROR
| input |
|---|
| 263528 |
| correct output |
|---|
| 3050239857553560 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 7
Verdict: RUNTIME ERROR
| input |
|---|
| 630093 |
| correct output |
|---|
| 41693157083373415 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 8
Verdict: RUNTIME ERROR
| input |
|---|
| 108426 |
| correct output |
|---|
| 212452122723676 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 9
Verdict: RUNTIME ERROR
| input |
|---|
| 407203 |
| correct output |
|---|
| 11253428501536410 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 10
Verdict: RUNTIME ERROR
| input |
|---|
| 798489 |
| correct output |
|---|
| 84851044799375085 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 11
Verdict: RUNTIME ERROR
| input |
|---|
| 699773 |
| correct output |
|---|
| 57111314541226175 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 12
Verdict: RUNTIME ERROR
| input |
|---|
| 535193 |
| correct output |
|---|
| 25549503060424365 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 13
Verdict: RUNTIME ERROR
| input |
|---|
| 951724 |
| correct output |
|---|
| 143675653860541900 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 14
Verdict: RUNTIME ERROR
| input |
|---|
| 997759 |
| correct output |
|---|
| 165549173593263040 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 15
Verdict: RUNTIME ERROR
| input |
|---|
| 368832 |
| correct output |
|---|
| 8362537201182784 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 16
Verdict: RUNTIME ERROR
| input |
|---|
| 497882 |
| correct output |
|---|
| 20569827174211084 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 17
Verdict: RUNTIME ERROR
| input |
|---|
| 235672 |
| correct output |
|---|
| 2181615649088424 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 18
Verdict: RUNTIME ERROR
| input |
|---|
| 721959 |
| correct output |
|---|
| 62717416230802340 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 19
Verdict: RUNTIME ERROR
| input |
|---|
| 328943 |
| correct output |
|---|
| 5932184601121240 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...Test 20
Verdict: RUNTIME ERROR
| input |
|---|
| 779320 |
| correct output |
|---|
| 78885627953685640 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 35, in <module>
main()...