Codeforces 835B - The number on the board Solution

  Solution in C++:

 ///La ilaha illellahu muhammadur rasulullah

///******Bismillahir-Rahmanir-Rahim******///

///AH Tonmoy

///Department of CSE,23rd batch

    ///Islamic University,Bangladesh

    1. #include <bits/stdc++.h>
    2. #define ll long long
    3. using namespace std;
    4. int main()
    5. {
    6. ll n,k,i,ss=0,r=0;
    7. string s;
    8. cin>>k>>s;
    9. sort(s.begin(),s.end());
    10. for(i=0;i<s.size();i++)
    11. ss+=s[i]-'0';
    12. for(i=0;i<s.size();i++)
    13. {
    14. if(ss>=k)
    15. break;
    16. while(s[i]<'9')
    17. {
    18. ss++;
    19. s[i]++;
    20. }
    21. r++;
    22. }
    23. cout<<r<<endl;
    24. }

    No comments

    Most View Post

    Recent post

    Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

        Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

    Powered by Blogger.