ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1104. Don’t Ask Woman about Her Age

1104 Time Limit Python 3
Posted by SergeyGlazkov 14 Oct 2019 07:29
1104 Task
Help me please, I cant understand how can i do my calculations faster?
I think that problem with slow input, but how else can i write it?

p.s. using stdin, stdout get Time Limit as well


maximal = 0
max_digit = -1

arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', \
       'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', \
       'U', 'V', 'W', 'X', 'Y', 'Z']

for s in input():
    number = arr.index(s)
    if max_digit < number:
        max_digit = number
    maximal += number

if max_digit == 0:
    print(2)
else:
    answer = ''
    for k in range(max_digit, 37):
        if not maximal % k:
            answer = k + 1
            break

    if answer == '':
        print('No solution.')
    else:
        print(answer)

Edited by author 14.10.2019 07:30

Edited by author 14.10.2019 07:41