답안 #258411

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
258411 2020-08-05T22:50:21 Z ipaljak Trol (COCI19_trol) C++14
50 / 50
0 ms 256 KB
#include <cstdio>

using namespace std;

typedef long long llint;

int q;

int main(void) {
  scanf("%d", &q);
  while (q--) {
    llint l, r;
    scanf("%lld%lld", &l, &r);
    llint tot = r - l + 1;
    llint sol = (tot / 9) * 9 * 10 / 2;
    for (int i = 0; i < tot % 9; ++i) {
      int add = (int) ((l + i) % 9);
      if (add == 0) add = 9;
      sol += (llint) add;
    }
    printf("%lld\n", sol);
  }
  return 0;
}

Compilation message

trol.cpp: In function 'int main()':
trol.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &q);
   ~~~~~^~~~~~~~~~
trol.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld", &l, &r);
     ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct