Submission #211885

# Submission time Handle Problem Language Result Execution time Memory
211885 2020-03-21T15:09:55 Z aloomya Trol (COCI19_trol) C++17
50 / 50
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
using PII = pair<int, int>;
const int MAX_N = 3e5 + 10, MOD = 1e9 + 7, INF = 3e18, NINF = -3e18;

int p[9] = {0, 1, 3, 6, 10, 15, 21, 28, 36}; 

int sol(int r){
    return (r / 9) * 45 + p[r % 9];
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie();
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
	int l, r;
	cin >> l >> r;
	cout << sol(r) - sol(l - 1) << endl;
    }
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct