题目大意: 有T组数组 l到r逐步加一变化了多少个数字
样例
Example input
4
1 9
9 10
10 20
1 1000000000
output
8
2
11
1111111110
每位数对答案的贡献是r-l
个位是r-l
十位是(r/10)-(l/10)
…
统计一下即可,难度八成是标错了。。。
AC代码:
#include <bits/stdc++.h>
using namespace std;
int main(){
int T,l,r;
scanf("%d",&T);
while(T--){
scanf("%d %d",&l,&r);
int ans=0;
for (int i=1;i<=10;i++){
ans+=r-l;
l/=10,r/=10;
}
printf("%d\n",ans);
}
return 0;
}
本来18号有邀请赛的,打算这段时间就不写题解了,结果最后还是去不了,,,就把之前写的题补一下把。