# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
975266 | vjudge1 | Trol (COCI19_trol) | C++17 | 1 ms | 432 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int maxn=1e5+5;
int main() {
int q; cin>>q;
while(q--) {
int l,r; cin>>l>>r;
if(l==r) cout<<l%9<<"\n";
else {
int m=l%9;
int p=9-m+1;
double sum1=((double)p/(double)2)*(m+9);
int o=l+(l%9)-1;
int k=r-o;
int a;
if(l==1)a=k/9-1;
else a=k/9;
int sum2=(9*(10)/2)*a;
int res=r%9;
int sum3=res*(res+1)/2;
cout<<sum1+sum2+sum3<<"\n";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |