Submission #1171719

#TimeUsernameProblemLanguageResultExecution timeMemory
1171719tatasTrol (COCI19_trol)C++17
10 / 50
0 ms328 KiB
/* Bismillah Medal Nama: Muhammad Tatas Maulana Sekolah: MAN Insan Cendekia Lombok Timur Member of Zevthasses Elmaerifa */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vll; #define pb push_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define endl '\n' const ll MOD = 1e9 + 7; const ll INF = 1e18; void solve() { ll l, r; cin >> l >> r; ll batas_atas = 0; ll batas_bawah = 0; if (r % 9 == 0) { batas_atas = r; } else { batas_atas = ((r / 9) + 1) * 9; } if (l % 9 == 1) { batas_bawah = l; } else { batas_bawah = ((l / 9)) * 9; } ll jumlah = (batas_atas - batas_bawah + 1) / 9; ll total = jumlah * (45); ll temp = 9; for (ll i = batas_atas; i > r; i--) { total -= temp; temp--; } temp = 1; for (ll i = batas_bawah + 1; i < l; i++) { total -= temp; temp++; } if (r % 9 == 0 && l % 9 == 0) { total += 9; } cout << total << endl; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; cin >> t; // Uncomment if multiple test cases while (t--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...