# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
691878 | delrey | Trol (COCI19_trol) | C++14 | 1 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
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(long long 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<<x<<" "<<y<<" ";
cout<<res<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |