답안 #491236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
491236 2021-12-01T06:07:57 Z ktkerem Trol (COCI19_trol) C++17
30 / 50
1000 ms 204 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll _i=0;
#define ffn(x) _i=x
#define llll pair<ll , ll>
#define stitr set<llll>::iterator
#define fora(y,x) for(ll y=_i;x>y;y++)
#define pb push_back
#define pf push_front
#define debu cout << "hello\n"
#define fi first
#define sec second
const ll limit = 1e9+7; 
const ll ous=1e5 + 5;
const ll dx[4] = {1 , -1 , 0 , 0} , dy[4] = {0,0,-1,1};
ll don(ll x){
    ll g = 0;
    while(x){
        g+=x%10;
        x/=10;
    }
    if(g >= 10){
        return don(g);
    }
    return g;
}
void solve(){
    ll q;cin >> q;
    while(q--){
        ll l ,r;cin >> l >> r;
        ll topl = 0;
        for(ll i = l;r >= i;i++){
            topl+=don(i);
        }
        cout << topl << "\n";
    }
    return;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0; 
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 3 ms 204 KB Output is correct
4 Execution timed out 1091 ms 204 KB Time limit exceeded
5 Execution timed out 1092 ms 204 KB Time limit exceeded