# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
209325 |
2020-03-13T19:59:37 Z |
papa |
Trol (COCI19_trol) |
C++14 |
|
5 ms |
376 KB |
#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 |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |