#P1451. L Absolute Sequence Number

L Absolute Sequence Number

题目描述

We defined a number between 10,00010,000 to 99,999,99999,999,999 as Absolute Sequence Number (abs_seqno) . And its last four digits is called as Sequence Number (seqno).

Now you need to implemente a function which will convert seqno to abs_seqno. The function is defined below:

int convert(int seqno, int checkpoint); 
 

In this function, given seqno and the recent absolute sequence number checkpoint, compute the abs_seqno that last four digits is seqno and is the closest to the checkpoint.

A checkpoint is essential because one seqno can correspond to many abs_seqno's. E.g. the seqno1717” corresponds to the abs_seqno of 1717, but also 10,000+1710,000+17, or 100,000+17100,000+17, or 1,000,000+171,000,000+17, etc. The checkpoint helps to resolve the ambiguity, as the recent converted abs_seqno that programmer of this function knows is close to the desired abs_seqno for current seqno. In your implementation, you’ll use a input value as the intitial checkpoint when first call the convert() , and use the recent result of convert() as checkpoint after call the function.

Note: We guarantee that there's NO abs_seqno greater than 99,999,99999,999,999 or less than 10,00010,000.

输入格式

输出格式

样例

8 3000000 
1 
2 
0 
9999 
5000 
4999 
5001 
1
3000001 
3000002 
3000000 
2999999 
2995000 
2994999 
2995001 
3000001