Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

Jonis's blog

By Jonis, 11 years ago, In English

I need a hint to solve problem F (password remembering) at ICPC DHAKA 2009.

I have tried to solve this problem for several days unsuccessfully...

At this link you can get a description and some comments about the questions:

http://www.northsouth.edu/acm/dhaka2009.pdf

The link of the problem in Live Archive is:

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=346&page=show_problem&problem=2499

I would appreciate any help. Thanks in advance!

  • Vote: I like it
  • +2
  • Vote: I do not like it

»
11 years ago, # |
  Vote: I like it -8 Vote: I do not like it

Hello,

I'm not sure if this is what you're looking for, but here is a solution in Python 2.7.5

It's not the most efficient solution xD But it worked for the sample problem

n=int(raw_input())

ab=[]

num=""
answers=[]


for i in xrange(n):
	ab.append(map(int, raw_input().split()))

for i in ab:
	ans=0
	for j in xrange(i[0],i[1]+1):
		num=str(j)[::-1]
		if(i[0] <= int(num) <= i[1]):
			ans+=1
	answers.append(ans)

blah=0

for i in answers:
	answernumber+=1
	print "Case "+str(answernumber)+": "+str(answers[answernumber-1])
  • »
    »
    11 years ago, # ^ |
    Rev. 2   Vote: I like it +6 Vote: I do not like it

    Thank you, but this is not what I was looking for, since the problem expects a logarithmic solution.

    I suggest you try A = 1 and B = 2**64 — 1.

    Unfortunatelly, this solution is too slow...

    Anyone have a better idea?

»
11 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Did you solve it? I did if you still asking for help