#include <iostream>
#include <cstdio>
using namespace std;
inline long long getsum(long long p, long long q){
return (p + q) *(q - p + 1) / 2;
}
long long p, q;
int main(){
while (scanf("%lld%lld", &p, &q)){
if(p < 0 && q < 0)break;
long long ans = 0;
while (p || q){
long long t1 = p % 10, t2 = q % 10;
if(q <= 10){
if(q == 10){
ans += getsum(t1, 9) + 1;
}else{
ans += getsum(t1, t2);
}
break;
}
if(t1){
ans += getsum(t1, 9);
}
if(t2){
ans += getsum(1, t2);
}
long long tp = 0, tq = 0;
if(t1 == 0 || p < 10)tp = p;
else tp = (p + 10 - t1);
if(t2 == 0 || q < 10)tq = q;
else tq = (q - t2);
ans += (tq - tp) / 10 * 45;
p = tp / 10;
q = tq / 10;
}
printf("%lld\n", ans);
}
return 0;
}
UVA 10994 Simple Addition
最新推荐文章于 2021-01-20 01:45:07 发布