Task: | Onnenluku |
Sender: | |
Submission time: | 2015-09-15 15:25:11 +0300 |
Language: | Python3 |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.21 s | 1 | details |
#2 | WRONG ANSWER | 0.23 s | 1 | details |
#3 | WRONG ANSWER | 0.22 s | 1 | details |
#4 | WRONG ANSWER | 0.23 s | 1 | details |
#5 | WRONG ANSWER | 0.22 s | 1 | details |
#6 | TIME LIMIT EXCEEDED | -- | 2 | details |
#7 | TIME LIMIT EXCEEDED | -- | 2 | details |
#8 | TIME LIMIT EXCEEDED | -- | 2 | details |
#9 | TIME LIMIT EXCEEDED | -- | 2 | details |
#10 | TIME LIMIT EXCEEDED | -- | 2 | details |
#11 | TIME LIMIT EXCEEDED | -- | 3 | details |
#12 | TIME LIMIT EXCEEDED | -- | 3 | details |
#13 | TIME LIMIT EXCEEDED | -- | 3 | details |
#14 | TIME LIMIT EXCEEDED | -- | 3 | details |
#15 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#!/usr/bin/env python3 # onnenluku # tasan kahta numeroa sisältävien lukujen määrä välillä a..b # esim. 1274 # rekursiolla yhdistelmien määrä eri etenemishaaroista: # - mitkä numerot on jo lukittu tässä haarassa # - onko paikan numerorajoite vielä voimassa (esim. 1274: 12xx on, 11xx ei) def laske(numerot_nurin, lukitut=[], rajoite=True): '''palauta tuplanumerolukujen määrä välillä 0...n numerot_nurin: n-luvun numerot lopusta alkuun, esim. 1274 -> [4, 7, 2, 1] lukitut: 0..2 uniikkia, yhdistelmiin lukittua numeroa rajoite: edetään numerot_nurin-luvun asettamaa ylärajaa pitkin ''' if not numerot_nurin: # yhdistelmä valmis, saatiinko se kahdella kasaan? return 1 if len(lukitut) == 2 else 0 yht = 0 nykyinen = numerot_nurin.pop() for x in range(1, 10): uusi_numero = x not in lukitut if len(lukitut) > 1 and uusi_numero: continue if rajoite and x > nykyinen: continue if uusi_numero: lukitut.append(x) yht += laske(numerot_nurin, lukitut, rajoite and x == nykyinen) if uusi_numero: lukitut.pop() if not lukitut: # ylärajaa lyhyemmät eli aina sitä pienemmät yhdistelmät yht += laske(numerot_nurin, lukitut, False) numerot_nurin.append(nykyinen) return yht def hidas(x): return sum(1 for x in range(1, x + 1) if len(set(str(x))) == 2 and '0' not in str(x)) def numerot_nurin(x): return [int(c) for c in str(x)[::-1]] def main(): a, b = map(int, input().strip().split()) ca = laske(numerot_nurin(a - 1), []) cb = laske(numerot_nurin(b), []) print(ca, cb, cb - ca) if __name__ == '__main__': main()
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
input |
---|
2157 93337 |
correct output |
---|
1421 |
user output |
---|
1788 75497 73709 |
Test 2
Group: 1
Verdict: WRONG ANSWER
input |
---|
4875 95124 |
correct output |
---|
1278 |
user output |
---|
3674 75512 71838 |
Test 3
Group: 1
Verdict: WRONG ANSWER
input |
---|
5577 96352 |
correct output |
---|
1245 |
user output |
---|
4579 75520 70941 |
Test 4
Group: 1
Verdict: WRONG ANSWER
input |
---|
8362 92950 |
correct output |
---|
1076 |
user output |
---|
7314 75494 68180 |
Test 5
Group: 1
Verdict: WRONG ANSWER
input |
---|
5658 96660 |
correct output |
---|
1238 |
user output |
---|
4586 75520 70934 |
Test 6
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
51312303535233 994542403556353 |
correct output |
---|
1453976 |
user output |
---|
(empty) |
Test 7
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
25636920452341 934558290712847 |
correct output |
---|
1544072 |
user output |
---|
(empty) |
Test 8
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
7917952071965 985207415843573 |
correct output |
---|
1763176 |
user output |
---|
(empty) |
Test 9
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
48991581181227 907034837225965 |
correct output |
---|
1380248 |
user output |
---|
(empty) |
Test 10
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
47968703305149 924246001328437 |
correct output |
---|
1396632 |
user output |
---|
(empty) |
Test 11
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
292953755324413237753216241025... |
correct output |
---|
53286731528535944 |
user output |
---|
(empty) |
Test 12
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
373990979330820426927419348165... |
correct output |
---|
51580289482227600 |
user output |
---|
(empty) |
Test 13
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
701417326319476057561825658890... |
correct output |
---|
42924933948374952 |
user output |
---|
(empty) |
Test 14
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
177202883511434557056457305647... |
correct output |
---|
54500592365600640 |
user output |
---|
(empty) |
Test 15
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
977665117437419620152569155919... |
correct output |
---|
38562071809359800 |
user output |
---|
(empty) |