4499小凯的数字

4499   小凯的数字

题目描述

小凯有一天突发奇想,写下了一串数字:lns="http://www.w3.org/1998/Math/MathML">l(l+1)(l+2)...(r-1)r

例如:lns="http://www.w3.org/1998/Math/MathML">l=2,r=5时,数字为:lns="http://www.w3.org/1998/Math/MathML">2345

lns="http://www.w3.org/1998/Math/MathML">l=8,r=12时数字为:lns="http://www.w3.org/1998/Math/MathML">89101112

小凯很喜欢数字 lns="http://www.w3.org/1998/Math/MathML">9,所以他想问你他写下的数字除以 lns="http://www.w3.org/1998/Math/MathML">9 的余数是多少

例如:lns="http://www.w3.org/1998/Math/MathML">l=2,r=5时,lns="http://www.w3.org/1998/Math/MathML">2345\,\,mod\,\,9 = 5

输入格式:

第一行为数字 lns="http://www.w3.org/1998/Math/MathML">Q,表示小凯有 lns="http://www.w3.org/1998/Math/MathML">Q 个问题

第 lns="http://www.w3.org/1998/Math/MathML">2 到 lns="http://www.w3.org/1998/Math/MathML">Q+1 行,每行两个数字 lns="http://www.w3.org/1998/Math/MathML">l,r 表示数字范围

输出格式:

对于每行的问题输出一行,一个数字,表示小凯问题的回答
输入样例 复制
3
1 999
123 456
13579 24680
输出样例 复制
0
6
0

说明

样例1解释:lns="http://www.w3.org/1998/Math/MathML">2345\,\,mod\,\,9 = 5   lns="http://www.w3.org/1998/Math/MathML">89101112\,\,mod\,\,9 = 5

30% 数据满足:lns="http://www.w3.org/1998/Math/MathML">Q\leq10;l,r\leq100

50% 数据满足:lns="http://www.w3.org/1998/Math/MathML">Q\leq100;l,r\leq10000

70% 数据满足:lns="http://www.w3.org/1998/Math/MathML">Q\leq1000;l,r\leq10^6

100%数据满足:lns="http://www.w3.org/1998/Math/MathML">Q\leq10000;0<l,r\leq10^{12} 且 lns="http://www.w3.org/1998/Math/MathML">l\leq r

5
8
通过提交
时空限制1000ms/128mb
题目来源NOIP2018 原创模拟题T1
评测方式在线评测
题目类型数论,基础联系
难        度