답안 #975930

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975930 2024-05-06T03:35:21 Z vjudge1 Trol (COCI19_trol) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n, l, r;
    cin >> n;
    long long ans1, ans2, ans; 
    for(int i = 0; i < n; i++){
        cin >> l >> r;
        ans = l - r + 1;
        if(l == r){
            cout << ans1 << endl;
        }
        l = l % 9;
        r = r % 9;
        else{
            if(ans > 9){
            ans1 = 45 * (ans / 9);
            }else if(l == 0){
                l = 9;
            }else if(r == 0){
                r = 9;
            }else if(l == 9){
                ans1 += 9;
                for(int i = 0; i <= r; i++){
                    ans1 += i;
                }
            }
        }cout << ans1 << endl;
        
    }
}

Compilation message

trol.cpp: In function 'int main()':
trol.cpp:16:9: error: 'else' without a previous 'if'
   16 |         else{
      |         ^~~~
trol.cpp:7:21: warning: unused variable 'ans2' [-Wunused-variable]
    7 |     long long ans1, ans2, ans;
      |                     ^~~~