답안 #975103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975103 2024-05-04T12:45:08 Z vjudge1 Trol (COCI19_trol) C++17
0 / 50
3 ms 604 KB
#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(1152921504606846976);
    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 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Runtime error 2 ms 604 KB Execution killed with signal 6
3 Runtime error 3 ms 600 KB Execution killed with signal 6
4 Runtime error 3 ms 604 KB Execution killed with signal 6
5 Runtime error 2 ms 600 KB Execution killed with signal 6