Submission #282988

#TimeUsernameProblemLanguageResultExecution timeMemory
282988AMO5Trol (COCI19_trol)C++17
50 / 50
1 ms384 KiB
#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 timeMemoryGrader output
Fetching results...