Skip to content

Commit 70f8fdb

Browse files
committed
Add files
1 parent 1fd6c28 commit 70f8fdb

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

CSES/Removing Digits.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include<bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
#define int long long
6+
#define M 1000000007
7+
#define N 300010
8+
9+
signed main(){
10+
11+
ios_base::sync_with_stdio(false);
12+
cin.tie(NULL);
13+
14+
int n;
15+
cin >> n;
16+
int dp[n+1];
17+
for(int i=0;i<=n;i++)
18+
dp[i]=INT_MAX;
19+
dp[0]=0;
20+
for(int i=1;i<=n;i++){
21+
int num=i;
22+
while(num>0){
23+
int val=num%10;
24+
num/=10;
25+
dp[i]=min(dp[i],dp[i-val]+1);
26+
}
27+
}
28+
cout << dp[n] << endl;
29+
}

0 commit comments

Comments
 (0)