Advertisement
MatveyL

Untitled

Oct 20th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <fstream>
  4. #include <math.h>
  5. using namespace std;
  6.  
  7. int main(){
  8. string b;
  9. long long a;
  10. int re = 0,it = 0,kek = 0;
  11. cin >> a;
  12. cin>>b;
  13. vector<int>A;
  14. for(int i = 0 ; i < b.size() ; i ++){
  15. A.push_back(int(b[i])-'0');
  16. }
  17. for (int i = 0 ; i < A.size() ; i ++ ) {
  18. kek += A[i];
  19. }
  20. if (kek > a){
  21. cout<<0<<endl;
  22. }
  23. else{
  24. for ( int i = 0 ; i < 10 ; i++ ){
  25. for ( int j = 0 ; j < A.size() ; j++ ){
  26. if(A[j] == i){
  27. kek = kek - A[j] + 9;
  28. A[j] = 9;
  29. re+=1;
  30.  
  31. }
  32.  
  33. if (kek >= a){
  34. it = 1;
  35. break;
  36. }
  37. }
  38.  
  39.  
  40. if (it ==1){
  41. break;
  42. }
  43. }
  44.  
  45. cout<<re;
  46. }
  47.  
  48. return 0 ;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement