답안 #377216

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
377216 2021-03-13T11:47:50 Z OptxPrime Trol (COCI19_trol) C++11
30 / 50
1 ms 492 KB
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>

using namespace std;

int f( int x )
{
    if( x%9 != 0 ) return x%9;
    else return 9;
}

int main()
{
    int q,l,r, suma;
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>l>>r;
        suma = 0;
        //cout << nadjiSumu(l,r)<<endl;
        int brojBlokova = (r-l+1)/9;
        suma = brojBlokova*45;
        int visak = (r-l+1)%9;
        if( visak!=0 ){
        int zadnji = f(r);
        int prvi = f(l);
        while( zadnji !=  prvi ){
            suma += zadnji;
            zadnji--;
            if( zadnji == 0 ) zadnji = 9;
        }
        suma += zadnji;
        }

        cout<<suma<<endl;
    }

return 0;
}





# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct