Submission #937088

# Submission time Handle Problem Language Result Execution time Memory
937088 2024-03-03T13:06:39 Z ASGA_RedSea Trol (COCI19_trol) C++17
50 / 50
1 ms 348 KB
/**

                                    * بسم الله الرحمن الرحيم *

                ﴾ رَبِّ اشْرَحْ لِي صَدْرِي * وَيَسِّرْ لِي أَمْرِي * وَاحْلُلْ عُقْدَةً مِّن لِّسَانِي * يَفْقَهُوا قَوْلِي ﴿

*/

/// author : "ASGA_RedSea"

#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

 #define endl '\n'

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const ll mod = 1000000007;

signed main(){
    ios_base::sync_with_stdio(0);
    ///cout.tie(0);
    cin.tie(0);

    ///cout << fixed << setprecision(6);

    ///freopen("test.in", "r", stdin);
    ///freopen("test.out", "w", stdout);

    int t;
    cin >> t;
    while(t--){
        ll l,r;
        cin >> l >> r;

        ll ans = 0;
        while(l <= r && (l % 9) != 1){
            ans += (l % 9 == 0 ? 9 : l % 9);
            l++;
        }
        while(r >= l && (r % 9) != 0){
            ans += r % 9;
            r--;
        }

        ans += ((r - l + 1) / 9) * 45;

        cout << ans << endl;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct