제출 #1256149

#제출 시각아이디문제언어결과실행 시간메모리
1256149utkuTrol (COCI19_trol)C++20
50 / 50
0 ms328 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef multiset<int> mi;

const int INF = 1e9 + 7;         
const ll LINF = 1e18 + 7;        
const int MOD = 1e9 + 7;         
const double EPS = 1e-9;         
const double PI = acos(-1.0);    

#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define F first
#define S second

int t;
vi ar = {9,1,2,3,4,5,6,7,8};


void solve() {
    ll l, r;
    cin >> l >> r;

    const ll n = 9;
    ll length = r - l + 1;

    ll full_cycles = length / n;
    ll remainder = length % n;

    ll distance = full_cycles * 45;

    int pos = l % n;  

    ll sum = 0;
    for (int i = 0; i < remainder; ++i) {
        sum += ar[(pos + i) % n];
    }

    cout << distance + sum << '\n';
}


int main() {
    fastio;
    //t=1;   -  cin >> t;
    cin >> t;
    while(t--) solve();
    return 0;
}

#Verdict Execution timeMemoryGrader output
Fetching results...