Submission #1007335

#TimeUsernameProblemLanguageResultExecution timeMemory
1007335vjudge1Trol (COCI19_trol)C++17
20 / 50
1095 ms348 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int digitSum(int num) { while (num >= 10) { int temp = 0; while (num > 0) { temp += num % 10; num /= 10; } num = temp; } return num; } int main() { int q; cin >> q; vector<pair<int, int>> queries(q); for (int i = 0; i < q; ++i) { int l, r; cin >> l >> r; queries[i] = {l, r}; } for (int i = 0; i < q; ++i) { int l = queries[i].first; int r = queries[i].second; ll ans = 0; for (int j = l; j <= r; ++j) { ans += digitSum(j); } cout << ans << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...