Submission #637244

# Submission time Handle Problem Language Result Execution time Memory
637244 2022-09-01T06:51:16 Z iee Trol (COCI19_trol) C++17
50 / 50
1 ms 212 KB
// iee
#include <bits/stdc++.h>

#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define fi first
#define se second
using ll = long long;
using ull = unsigned long long;
using namespace std;
void work(int);

template <class T> void read(T &x) {
  x = 0; int f = 1, ch = getchar();
  while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
  while (isdigit(ch)) x = x * 10 + (ch - '0'), ch = getchar();
  x *= f;
}

int main() {
  int TT = 1;  cin >> TT;
  rep(CAS, 1, TT)
    work(CAS);
  return 0;
}

void work(int CASE) {
  ll l, r;
  cin >> l >> r;
  ll lun = (r - l + 1) / 9;
  ll ans = lun * 45;
  rep(i, l + lun * 9, r) ans += (i % 9 == 0 ? 9 : i % 9);
  cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct