#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
//ll N = 1152921504606846976;
//vector<ll> sum(N+1);
/*
void bruteforce(ll n){
for(ll i = 1; i <= n; i++){
ll t = i;
ll m;
while(t > 0){
m = t%10;
sum[i] += m;
t /= 10;
}
}
}
*/
int main(){
//bruteforce(N);
vector<ll> sum(10);
int q; cin >> q;
while(q--){
ll l, r; cin >> l >> r;
ll ans = 0;
for(ll i = l; i <= r; i++){
ll t = i;
ll m = 0;
while(t > 0){
m = t % 10;
sum[i] += m;
t /= 10;
}
ans += sum[i];
}
cout << ans << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
3 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
4 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
5 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |