n = int(input())
sz = 1
last = 1
prev = 0
i = 2
while (sz < n):
prev = last
last += (i*2)-1
sz += i
i+=1
if(sz == n):
print(last % 10)
else :
while(sz > n and prev < last):
last -= 2
sz -= 1
print(last)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2796 KB |
Output is correct |
2 |
Correct |
16 ms |
2796 KB |
Output is correct |
3 |
Correct |
16 ms |
2796 KB |
Output is correct |
4 |
Correct |
19 ms |
2796 KB |
Output is correct |
5 |
Correct |
20 ms |
2796 KB |
Output is correct |
6 |
Correct |
35 ms |
2796 KB |
Output is correct |
7 |
Execution timed out |
2033 ms |
2796 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |