Submission #346939

#TimeUsernameProblemLanguageResultExecution timeMemory
346939NursikTrol (COCI19_trol)C++14
50 / 50
1 ms364 KiB
#include <bits/stdc++.h> #define f first #define s second #define ll long long #define pb push_back #define all(v) v.begin(),v.end() #define ld long double #define fi first #define se second using namespace std; void data() { #ifdef NURS freopen("main.in", "r", stdin); freopen("main.out", "w", stdout); #endif } void win() { ios_base::sync_with_stdio(0), cin.tie(0),cout.tie(0); } int block = 400; const ld eps = 1e-7; const int N = 3e5 + 500; const int mod = 1e9 + 7; const int mod2 = 998244353; const ll hh = 29; const ll hh2 = 31; int t, sum; main() { data(); win(); cin >> t; while (t--) { ll l, r; cin >> l >> r; ll prev = l; ll ans = 0; while (l <= r) { prev = l; while (prev / 10 > 0) { sum = 0; while (prev > 0) sum += prev % 10, prev /= 10; prev = sum; } ans += prev; if (prev == 9) break; l++; } while (r > l) { prev = r; while (prev / 10 > 0) { sum = 0; while (prev > 0) sum += prev % 10, prev /= 10; prev = sum; } ans += prev; if (prev == 1) break; r--; } // cout << l << " " << r << '\n'; cout << ans + (r - l - 1) / 9 * 9 * 10 / 2 << '\n'; } } /* Если я солью, то я обязательно затащю */

Compilation message (stderr)

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