Submission #249499

# Submission time Handle Problem Language Result Execution time Memory
249499 2020-07-15T07:03:07 Z shafinalam Trol (COCI19_trol) C++14
50 / 50
1 ms 256 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
    int T;
    scanf("%d", &T);

    while(T--)
    {
        ll l, r;
        cin >> l >> r;
        ll sum = 0;
        while(l<=r && (l%9)!=1)
        {
            ll x = l%9;
            if(x==0) x = 9;
            sum+=x;
            l++;
        }
        while(r>=l && (r%9)!=0)
        {
            sum+=(r%9);
            r--;
        }
        if(r-l+1>0)
        {
            ll len = (r-l+1)/9;
            sum+=(len*45);
        }
        cout << sum << '\n';
    }
    return 0;
}

Compilation message

trol.cpp: In function 'int main()':
trol.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &T);
     ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct