# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
250650 | oko | Trol (COCI19_trol) | C++14 | 1 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int num(long long x)
{
if((x%10)==x)return x;
long long y=0;
while(x)
{
y+=(x%10);
x/=10;
}
return num(y);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
int t;
cin>>t;
while(t--)
{
long long l,r,sum=0,f=0,ni=(1+2+3+4+5+6+7+8+9);
cin>>l>>r;
while(true)
{
int x=num(l);
sum+=x;
if(x==9)break;
if(l==r)
{
f=1;
break;
}
l++;
}
while(true)
{
int x=num(r);
if(f||x==9)break;
sum+=x;
r--;
}
cout<<sum+(((r-l)/9)*ni)<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |