303420: CF662D. International Olympiad
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
International Olympiad
题意翻译
题目描述 奥林匹克缩写竞赛从$1989$年起每年举行一次。每年组委会都会将该年的缩写定为$IAO'x$的形式,其中$x$是当前年份未在之前的年份中使用过的非空最短后缀。比如说:$1989,1990,1991$年的缩写分别是$IAO'9,IAO'0,IAO'1$,但是$2015$年的缩写是$IAO'15$,因为$1995$年已经使用过$IAO'5$了。 现在给你一系列$IAO'x$形式的缩写,试判断这些缩写分别是哪一年奥林匹克缩写竞赛的缩写。 输入数据 第一行一个正整数$T(1 \leq T \leq 1000)$表示数据组数,接下来$T$行每行一个形如$IAO'x$的字符串表示缩写。保证$x < 10^9$ 输出数据 对于每一组输入数据对应一行输出其对应年份。题目描述
International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of form IAO'y, where $ y $ stands for some number of consequent last digits of the current year. Organizers always pick an abbreviation with non-empty string $ y $ that has never been used before. Among all such valid abbreviations they choose the shortest one and announce it to be the abbreviation of this year's competition. For example, the first three Olympiads (years 1989, 1990 and 1991, respectively) received the abbreviations IAO'9, IAO'0 and IAO'1, while the competition in 2015 received an abbreviation IAO'15, as IAO'5 has been already used in 1995. You are given a list of abbreviations. For each of them determine the year it stands for.输入输出格式
输入格式
The first line of the input contains a single integer $ n $ ( $ 1<=n<=1000 $ ) — the number of abbreviations to process. Then $ n $ lines follow, each containing a single abbreviation. It's guaranteed that each abbreviation contains at most nine digits.
输出格式
For each abbreviation given in the input, find the year of the corresponding Olympiad.
输入输出样例
输入样例 #1
5
IAO'15
IAO'2015
IAO'1
IAO'9
IAO'0
输出样例 #1
2015
12015
1991
1989
1990
输入样例 #2
4
IAO'9
IAO'99
IAO'999
IAO'9999
输出样例 #2
1989
1999
2999
9999