# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
727718 | ilhan_arda | Trol (COCI19_trol) | C++17 | 1 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fi first
#define se second
#define pb push_back
#define int long long
using namespace std;
typedef long long ll;
typedef tuple<int, int, int> iii;
int t=1+2+3+4+5+6+7+8+9;
int mod(int x){
int r= x%9;
if(!r)r=9;
return r;
}
int32_t main(){
int q;
cin>>q;
while(q--){
int l, r;
cin>>l>>r;
int ans=0;
bool c=false;
for(int i=mod(l);i<=9;i++){
ans+=i;
if(l+(i-l%9)==r){
c=true;
break;
}
}
if(c){
cout<<ans<<endl;
continue;
}
l+=9-mod(l)+1;
for(int i=1;i<=r%9;i++){
ans+=i;
}
r-=r%9;
ans+=(r-l+1)/9*t;
cout<<ans<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |