답안 #971256

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971256 2024-04-28T09:12:47 Z vjudge1 Trol (COCI19_trol) C++
0 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
int sumDigits(long long num) {
  long long sum = 0;
  while (num > 0) {
    sum += num % 10;
    num /= 10;
  }
  if(sum>9){
    return sumDigits(sum);
  }else{
    return sum;
  }
}
int main(){
    int q;
    cin>>q;
    while (q--)
    {
        long long l,r;
        cin>>l>>r;
        long long awal=sumDigits(l);
        long long akhir=sumDigits(r);
        long long yang_akan_dikurangi;
        if(r%9!=0){
        yang_akan_dikurangi=(((r+(9-(r%9)))-(l-(l%9)))/9)*45;
        }else{
        yang_akan_dikurangi=(((r)-(l-(l%9)))/9)*45;
        }
        cout<<yang_akan_dikurangi-(((awal-1)*(awal))/2)-((9-akhir)*(10+akhir)/2)<<endl;
    }
    
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Incorrect 1 ms 348 KB Output isn't correct