답안 #651561

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
651561 2022-10-19T10:43:20 Z edogawa_something Trol (COCI19_trol) C++17
30 / 50
1000 ms 316 KB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef string st;
typedef bool bl;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
#define pu push
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0);cin.tie();
#define test ll qqqqq;cin>>qqqqq;while(qqqqq--)
#define F first
#define S second
#define forn(i,n) for(ll i=0;i<n;i++)
#define forx(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define pob pop_back
#define all(v) v.begin(),v.end()
#define lb lower_bound
#define ub upper_bound
#define pof pop_front
#define pow powww
const ll dx[]{1,0,-1,0};
const ll dy[]{0,-1,0,1};
const ll inf=2e18;
const ll mod=1e9+7;
const ll M=1e6+1;
const ll MM=202;
const ll MMM=101;
const ld pi=acos(-1);
const ll mod1=1000000321;
ll chk(ll x){
    ll ret=x;
    while(ret%10<ret){
    x=ret;
    ret=0;
    while(x>0){
        ret+=x%10;
        x/=10;
    }
    }
    return ret;
}
ll ans=0;
int main(){
    fast
    test{
        ans=0;
        ll l,r;
        cin>>l>>r;
        while(chk(l)!=0&&l<=r){
            ans+=chk(l);
            l++;
        }
        while(chk(r)!=9&&r>=l)
        ans+=chk(r),r--;
        ans+=((r-l+1)/10)*45;
        cout<<ans<<'\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 316 KB Output is correct
3 Correct 5 ms 212 KB Output is correct
4 Execution timed out 1092 ms 316 KB Time limit exceeded
5 Execution timed out 1073 ms 212 KB Time limit exceeded