# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
735262 | 2023-05-03T19:00:37 Z | aykhn | Trol (COCI19_trol) | C++14 | 1 ms | 340 KB |
#include <bits/stdc++.h> /* author: aykhn 5/1/2023 */ using namespace std; typedef long long ll; const int oo = INT_MAX; const ll ooo = LONG_MAX; const ll mod = 1e9 + 7; #define OPT ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define pii pair<int,int> #define pll pair<ll,ll> #define all(v) v.begin(), v.end() #define mpr make_pair #define pb push_back #define ts to_string #define fi first #define se second #define inf 0x3F3F3F3F #define tos to_string #define infll 0x3F3F3F3F3F3F3F3FLL #define bpc __builtin_popcount #define print(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout<<endl; char make(int i) { string s = tos(i); while (s.length() > 1) { int x = 0; for (int j = 0; j < s.length(); j++) x += s[j] - '0'; s = tos(x); } return s[0]; } int main() { OPT; int q; cin >> q; while (q--) { ll l, r; cin >> l >> r; ll res = 0; while ((l - 1)%9 + 1 != 1 && l <= r) { res += (l - 1)%9 + 1; l++; } while ((r - 1)%9 + 1 != 9 && l <= r) { res += (r - 1)%9 + 1; r--; } if (l > r) { cout << res << endl; continue; } cout << res + (r - l + 1)*5 << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 324 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |