| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1083931 | AliHasanli | Trol (COCI19_trol) | C++17 | 1 ms | 348 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
long long sum(long long a,long long b)
{
    long long ans=0;
    for(long long i=a;i<=b;i++)
    {
        if(i%9==0)ans+=9;
        ans+=i%9;
    }
    return ans;
}
long long solve(long long a,long long b)
{
    if(b-a<=20)return sum(a,b);
    long long a2=a,b2=b,ans=0;
    if(a%9!=1)a2+=(10-a%9);
    if(b%9!=0)b2-=b%9;
    //cout<<a2<<" "<<b2<<endl;
    ans+=sum(a,a2-1);
    ans+=sum(b2+1,b);//cout<<ans<<endl;
    ans+=(b2-a2+1)/9*45;
    return ans;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        long long a,b;
        cin>>a>>b;
        cout<<solve(a,b)<<endl;
    }
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
