| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 209325 | papa | Trol (COCI19_trol) | C++14 | 5 ms | 376 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;
typedef long long ll;
int q;
ll l,r;
//caka je u tome sto je taj niz periodican
//jer suma cifara daje isti ostatak kao i sam taj broj
//pa ce onda redom da budu 1,2,3,4,5,6,7,8,9,1...
//pronadjemo granice i onda samo vidimo koliko se takvih intervala pojavljuje
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cerr.tie(0);
   cin >> q;
   while(q--)
   {
       cin >> l >> r;
       ll sol = 0;
       if(r-l<=20)
       {
            for(ll i=l;i<=r;i++)
               sol = sol + (i%9==0) ? 9 : i%9;
            cout << sol << "\n";
       }
       else
       {
             while(1)
             {
               if((l%9)==1) break;
               else
               {
                   sol+=((l%9)==0) ? 9 : (l%9);
                   l++;
               }
             }
             while(1)
             {
               if((r%9)==0) break;
               else
               {
                   sol+=(r%9);
                   r--;
               }
             }
             ll cnt = r-l+1;
             sol+=cnt*5;
             cout << sol << "\n";
         }
   }
   return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
