제출 #1312718

#제출 시각아이디문제언어결과실행 시간메모리
1312718rizwarmcgovneyTrol (COCI19_trol)C++20
20 / 50
1095 ms396 KiB
#include <bits/stdc++.h> int main(){ int q; std::cin >> q; int l[q], r[q]; for(int i = 0;i < q;i++){ std::cin >> l[i] >> r[i]; } for(int i = 0;i < q;i++){ int res = 0; for(int j = l[i];j <= r[i];j++){ int num = j; if(num > 9){ std::string stringified = std::to_string(num); while(stringified.size() > 1){ int pt = 0; for(int k = 0;k < stringified.size();k++){ pt += stringified[k] - '0'; } if(pt > 9){ stringified = std::to_string(pt); }else{ num = pt; break; } } } res += num; } std::cout << res << std::endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...