제출 #1256873

#제출 시각아이디문제언어결과실행 시간메모리
1256873ipeksoysalTrol (COCI19_trol)C++20
50 / 50
0 ms328 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

main() 
{
    
    int n, a, b, top;
    cin >> n;
    
    for(int i=0; i<n; i++){
      top=0;
      cin>> a >>  b;
      
      if(b-a+1>9){
        int cark = b - a + 1;
        cark -= 9 - a%9 + 1;
        cark -= b%9;
        cark = cark / 9;
        top += cark * 45;
        int A = a;
        int B = b;
        for(int y=1; y<= 9 - A%9 + 1; y++){
          if(a%9==0)
            top+=9;
          else
            top+=a%9;
          a++;
        }
        for(int y=1; y<= B%9; y++){
          if(b%9==0)
            top+= 9;
          else
            top+=b%9;
          b--;
        }
      }
      else{
        for(int y=a; y<=b; y++){
          top+=y%9;
          if(y%9==0)
            top+=9;
        }
      }
      
      cout << top << "\n";
    }
    
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

trol.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...