Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <fstream>
- #include <math.h>
- using namespace std;
- int main(){
- string b;
- long long a;
- int re = 0,it = 0,kek = 0;
- cin >> a;
- cin>>b;
- vector<int>A;
- for(int i = 0 ; i < b.size() ; i ++){
- A.push_back(int(b[i])-'0');
- }
- for (int i = 0 ; i < A.size() ; i ++ ) {
- kek += A[i];
- }
- if (kek > a){
- cout<<0<<endl;
- }
- else{
- for ( int i = 0 ; i < 10 ; i++ ){
- for ( int j = 0 ; j < A.size() ; j++ ){
- if(A[j] == i){
- kek = kek - A[j] + 9;
- A[j] = 9;
- re+=1;
- }
- if (kek >= a){
- it = 1;
- break;
- }
- }
- if (it ==1){
- break;
- }
- }
- cout<<re;
- }
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement