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 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

      Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

    Powered by Blogger.