답안 #976256

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976256 2024-05-06T10:59:33 Z vjudge1 Trol (COCI19_trol) C++17
50 / 50
1 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int f(int x) {
  int ans = x/9;
  ans *= 45;

  int leftover = x%9;
  ans += leftover * (leftover+1)/2;
  return ans;
}

void solve() {
  int l,r;cin>>l>>r;
  cout << f(r) - f(l-1) << endl;
}

int32_t main() {
  ios_base::sync_with_stdio(0);cin.tie(NULL);
  int t;cin>>t;
  while (t--) solve();

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct