# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973907 | vjudge1 | Star triangles (IZhO11_triangle) | C++17 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// #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 |
---|---|---|---|---|
Fetching results... |