Submission #238743

#TimeUsernameProblemLanguageResultExecution timeMemory
238743HalitTrol (COCI19_trol)C++17
30 / 50
1095 ms384 KiB
#include <bits/stdc++.h> using namespace std; const bool cannot = 0; int main(){ int q; cin >> q; while(q--){ long long l,r, ans = 0, sootnp, lp = 0, rp = 0, ran_l, ran_r; cin >> l >> r; if(r - l + 1 <= 9){ for(int i = l;i <= r;i++) ans += i % 9 + (i % 9 == 0) * 9; cout << ans << "\n"; continue; } for(int i = l;i <= min(r , l+9) ;i++){ if(i % 9 == 1){ ran_l = i; break; } } for(int i = r;i >= max(l, r - 9);i--){ if(i % 9 == 1){ ran_r = i; break; } } sootnp = (ran_r - ran_l + 1) / 9 * 45; for(int i = l;i < ran_l;i++) lp += i % 9 + (i % 9 == 0) * 9; for(int i = r;i >= ran_r;i--) rp += i % 9 + (i % 9 == 0) * 9; ans = sootnp + lp + rp; cout << ans << "\n"; } } // ans = sum_of_one_to_nine_parts + left_part + right_part; // sootnp starts with 1 and ends with 9 // reminders are same (1,9 -> 0) ^^^^ // for loop to find beginning and end // sootnp = (range_length + 1) / 9 * 45 // find rigth&left_part with for

Compilation message (stderr)

trol.cpp: In function 'int main()':
trol.cpp:32:19: warning: 'ran_r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   sootnp = (ran_r - ran_l + 1) / 9 * 45;
             ~~~~~~^~~~~~~
trol.cpp:32:19: warning: 'ran_l' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...