Author: lllyouo
Date: 20250702
tag: 同余、快速幂
link: https://www.luogu.com.cn/problem/P4942问题描述
分析
一个数字除以
又因为每两位数字数字只差为
避免除法,则求
当然,
参考代码
cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int T; cin >> T;
while (T--) {
long long l, r; cin >> l >> r;
long long ans = (l + r) % 9 * ((r - l + 1) % 9) * 5 % 9;
cout << ans << endl;
}
return 0;
}