Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
Language:
String's Puzzle
Time Limit: 1000MSMemory Limit: 65536K
Total Submissions: 2592Accepted: 1026

Description

Zhu Ming and Small Li find a strange stone tablet, which has some capitals printed on it. Capitals in every string are different with each other, and every capital string is followed by a number. Because of their supernormal intelligence, Zhu Ming and Small Li find the number following the string is numbered in the order of dictionary sequence from little to big (the original number is 0).For example, when the length of capital string is 3, number following the string will be:
 
ABC0
ABD1
…… 
ZYX15599

To better study this puzzle, please make a program to given a n-length string (1<=n<=26), output the number of the string.

Input

There are several test cases.
Each data is made up of two lines.
The first line is number n (1<=n<=26)
The second line is a string with its length of n.
n=0 means end of the input.

Output

Output the string number for each group of data tested.

Sample Input

3
ABC
3
ZYX 
3
ABD
4
ABCD
0

Sample Output

0
15599
1
0

Source

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator