Submission #67532979
Source Code Expand
def to_base(n, b):
if n == 0:
return "0"
tr = ""
while n > 0:
tr += str(n % b)
n //= b
return tr[::-1]
def is_palindrome(s):
return s == s[::-1]
def solve(lim):
res = 0
for i in range(1, 10**6):
s = str(i)
pal = int(s + s[::-1])
if pal > lim:
break
if is_palindrome(to_base(pal, a)):
res += pal
for i in range(1, 10**6):
s = str(i)
pal = int(s + s[:-1][::-1])
if pal > lim:
break
if is_palindrome(to_base(pal, a)):
res += pal
print(res)
a = int(input())
n = int(input())
solve(n)
Submission Info
| Submission Time | |
|---|---|
| Task | C - Palindromic in Both Bases |
| User | regomal |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 350 |
| Code Size | 708 Byte |
| Status | AC |
| Exec Time | 2675 ms |
| Memory | 83084 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 350 / 350 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-01.txt | AC | 61 ms | 76320 KiB |
| 00-sample-02.txt | AC | 1083 ms | 82468 KiB |
| 00-sample-03.txt | AC | 1231 ms | 83084 KiB |
| 01-01.txt | AC | 60 ms | 76388 KiB |
| 01-02.txt | AC | 60 ms | 76580 KiB |
| 01-03.txt | AC | 2675 ms | 82620 KiB |
| 01-04.txt | AC | 1572 ms | 82740 KiB |
| 01-05.txt | AC | 1045 ms | 82696 KiB |
| 01-06.txt | AC | 1315 ms | 83056 KiB |
| 01-07.txt | AC | 1153 ms | 82756 KiB |
| 01-08.txt | AC | 1051 ms | 82864 KiB |
| 01-09.txt | AC | 1811 ms | 82832 KiB |
| 01-10.txt | AC | 1208 ms | 82908 KiB |
| 01-11.txt | AC | 59 ms | 76296 KiB |
| 01-12.txt | AC | 129 ms | 82552 KiB |
| 01-13.txt | AC | 60 ms | 76440 KiB |
| 01-14.txt | AC | 132 ms | 82624 KiB |
| 01-15.txt | AC | 58 ms | 76308 KiB |
| 01-16.txt | AC | 73 ms | 82448 KiB |
| 01-17.txt | AC | 58 ms | 76348 KiB |
| 01-18.txt | AC | 74 ms | 82908 KiB |
| 01-19.txt | AC | 1637 ms | 82848 KiB |
| 01-20.txt | AC | 63 ms | 81200 KiB |
| 01-21.txt | AC | 72 ms | 82512 KiB |
| 01-22.txt | AC | 59 ms | 76224 KiB |
| 01-23.txt | AC | 66 ms | 80932 KiB |
| 01-24.txt | AC | 65 ms | 81148 KiB |
| 01-25.txt | AC | 72 ms | 82320 KiB |
| 01-26.txt | AC | 71 ms | 82732 KiB |
| 01-27.txt | AC | 120 ms | 82536 KiB |
| 01-28.txt | AC | 58 ms | 76212 KiB |
| 01-29.txt | AC | 57 ms | 76624 KiB |
| 01-30.txt | AC | 58 ms | 76500 KiB |