Submission #973907

#TimeUsernameProblemLanguageResultExecution timeMemory
973907vjudge1Star triangles (IZhO11_triangle)C++17
0 / 100
1 ms348 KiB
// #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 timeMemoryGrader output
Fetching results...