Submission #282988

# Submission time Handle Problem Language Result Execution time Memory
282988 2020-08-25T08:17:19 Z AMO5 Trol (COCI19_trol) C++17
50 / 50
1 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()  
#define sz(x) int(x.size()) 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=63;
bool DEBUG=0;

ll calc(ll x){
	ll res=x/9;
	res*=45;
	res+=(x%9+1)*(x%9)/2ll;
	return res;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    while(n--){
		ll le,ri;
		cin>>le>>ri;
		cout<<calc(ri)-calc(le-1)<<"\n";
	}
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct