Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
---|---|---|---|---|---|---|
| discuss10940 - | Accepted | Python | 1.260 | 0.000 | 3706 | 5 mins ago |
Suggest:
- After readed problem, We feel problem need find a rule to solve
- How to find a rule in competitive programming ?
- Often we need show many result from min n
Col: A = input, B = output
Rule:
- If input is 2^x, we have output = input
- Else output is y_current = y_previous + 2
Code Python:
b = 0
a = 2
d = {}
while True:
e = a**b
if e > 500000:
break
d[e] = True
b += 1
v = 2
r = {}
for i in range(1, 500000):
if i in d:
v = 2
r[i] = i
else:
r[i] = v
v += 2
while True:
n = int(input())
if n == 0:
break
print(r[n])