Submission #160334

#TimeUsernameProblemLanguageResultExecution timeMemory
160334model_codeTrol (COCI19_trol)C++17
30 / 50
1078 ms376 KiB
#include <cstdio>

using namespace std;

typedef long long llint;

int q;

int value(llint x) {
  if (x < 10) return (int) x;
  llint sum = 0;
  while (x) {
    sum += (llint) (x % 10);
    x /= 10;
  }
  return value(sum);
}

int main(void) {
  scanf("%d", &q);
  while (q--) {
    llint l, r;
    scanf("%lld%lld", &l, &r);
    int sol = 0;
    for (llint i = l; i <= r; ++i) {
      sol += value(i);
    }
    printf("%d\n", sol);
  }
  return 0;
}

Compilation message (stderr)

trol.cpp: In function 'int main()':
trol.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &q);
   ~~~~~^~~~~~~~~~
trol.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld", &l, &r);
     ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...