#P1451. L Absolute Sequence Number
L Absolute Sequence Number
题目描述
We defined a number between to 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 seqno
“” corresponds to the abs_seqno
of , but also , or , or , 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 or less than .
输入格式
输出格式
样例
8 3000000
1
2
0
9999
5000
4999
5001
1
3000001
3000002
3000000
2999999
2995000
2994999
2995001
3000001