Submission #871596

#TimeUsernameProblemLanguageResultExecution timeMemory
871596vjudge1Trol (COCI19_trol)C++17
30 / 50
1091 ms500 KiB
//author: Ahmet Alp Orakci #include <bits/stdc++.h> using namespace std; using i64 = long long; #define int i64 int calc(int x) { int res = 0; while(x) { res += x % 10; x /= 10; } return res; } #define ONLINE_JUDGE void solve() { int l, r; cin >> l >> r; int ans = 0; for(int i = l; i <= r; i++) { int x = i; while(calc(x) != x) { x = calc(x); } ans += x; } cout << ans << "\n"; return; } signed main() { #ifndef ONLINE_JUDGE freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; cin >> t; for(int i = 1; i <= t; i++) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...