Submission #199472

#TimeUsernameProblemLanguageResultExecution timeMemory
199472SamAndTrol (COCI19_trol)C++17
50 / 50
5 ms376 KiB
#include <bits/stdc++.h> using namespace std; const int N = 102; int dp[N]; int sum(int x) { int ans = 0; while (x) { ans += (x % 10); x /= 10; } return ans; } long long p(long long x) { if (x == 0) return 0; long long ans = 0; ans += (x / 9) * (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9); for (int i = 1; i <= (x % 9); ++i) ans += i; return ans; } int main() { /*for (int i = 1; i < N; ++i) { if (i <= 9) dp[i] = i; else dp[i] = dp[sum(i)]; printf("%d %d\n", i, dp[i]); }*/ int tt; scanf("%d", &tt); while (tt--) { long long l, r; scanf("%lld%lld", &l, &r); printf("%lld\n", p(r) - p(l - 1)); } return 0; }

Compilation message (stderr)

trol.cpp: In function 'int main()':
trol.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &tt);
     ~~~~~^~~~~~~~~~~
trol.cpp:44:14: 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...