# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
691871 |
2023-01-31T19:41:15 Z |
delrey |
Trol (COCI19_trol) |
C++14 |
|
1 ms |
340 KB |
#include <iostream>
using namespace std;
int long Sum(int l, int r)
{
int ret = 0;
for(int i = l; i <= r; i++)
ret += i;
return ret;
}
int main()
{
int q;
long long a, b;
cin>>q;
int sum9 = Sum(1, 9);
while(q--)
{
cin>>a>>b;
long long x = a, y = b, res = 0;
if(y - x < 20)
{
for(int i = x; i <= y; i++)
{
res += i % 9;
if(i % 9 == 0)
res += 9;
}
cout<<res<<endl;
continue;
}
if(a % 9)
{
x += 9 - (x % 9);
res += Sum(a % 9, 9);
}
if(b % 9)
{
y -= y % 9;
res += Sum(1, b % 9);
}
if(a == x)
res += 9;
res += (y - x) / 9 * sum9;
cout<<res<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |