# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1254666 | masewera | Trol (COCI19_trol) | C++20 | 0 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
int t;
cin>>t;
while(t--)
{
int final=0,h,l,r,a,b;
cin>>l>>r;
h=r-l;
b=(r-1)%9+1;
a=(l-1)%9+1;
if(h/10 > 1)
{
h=h-9+a-b;
final+=(h/9)*45;
final+=(b+1)*b/2;
final+=45-((a-1)*(a)/2);
}
else
{
h++;
while(h--)
{
final+=a;
a++;
if(a%10==0) a=1;
}
}
cout<<final<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |