답안 #968637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968637 2024-04-23T18:59:44 Z VMaksimoski008 Trol (COCI19_trol) C++14
20 / 50
1000 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main() {
    int q;
    cin >> q;

    auto query = [&](ull p) {
        if(!p) return 0ull;
        int full = p / 9;
        ull ans = full * 45;
        for(ull i=full*9+1; i<=p; i++) ans += i % 9;
        return ans;
    };

    while(q--) {
        ull l, r;
        cin >> l >> r;
        cout << query(r) - query(l-1) << '\n';
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Execution timed out 1091 ms 348 KB Time limit exceeded
4 Incorrect 1 ms 348 KB Output isn't correct
5 Execution timed out 1085 ms 348 KB Time limit exceeded