Submission #1257377

#TimeUsernameProblemLanguageResultExecution timeMemory
1257377symbioterTrol (COCI19_trol)C++20
50 / 50
0 ms324 KiB
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
using namespace std;

ll f(ll x){
  ll ret = (x/9) * 45;
  for(int i = 1; i <= x % 9 ;i++) ret += i;
  return ret;
}

void work(){
  ll l, r; cin >> l >> r;
  cout << f(r) - f(l-1) << endl;
}
int main(){
  ios_base::sync_with_stdio(0);cin.tie(0);
  int t = 1; cin >> t;
  while(t--)work();
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...