# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
975930 | 2024-05-06T03:35:21 Z | vjudge1 | Trol (COCI19_trol) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; int main(){ long long n, l, r; cin >> n; long long ans1, ans2, ans; for(int i = 0; i < n; i++){ cin >> l >> r; ans = l - r + 1; if(l == r){ cout << ans1 << endl; } l = l % 9; r = r % 9; else{ if(ans > 9){ ans1 = 45 * (ans / 9); }else if(l == 0){ l = 9; }else if(r == 0){ r = 9; }else if(l == 9){ ans1 += 9; for(int i = 0; i <= r; i++){ ans1 += i; } } }cout << ans1 << endl; } }