Submission #973907

# Submission time Handle Problem Language Result Execution time Memory
973907 2024-05-02T12:42:03 Z vjudge1 Star triangles (IZhO11_triangle) C++17
0 / 100
1 ms 348 KB
// #include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll L, R;
int q;

ll f_(ll a)
{
    if (a == 0)
        return 0;
    return a % 10 + f_(a / 10);
}

ll f(ll a)
{
    ll hold = f_(a);
    if (hold > 9)
        return f(hold);
    return hold;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> q;

    while (q--)
    {
        cin >> L >> R;
        ll sum = 0;
        for (int i = L; i <= R; i++)
        {
            sum += f(i);
        }
        cout << sum << endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -