Codeforces Round 863 (Div. 3) 1811A. Insert Digit Solution
Problem Link : https://codeforces.com/contest/1811/problem/A
Solution in C++:
- /// Author : AH_Tonmoy
 - #include <bits/stdc++.h>
 - using namespace std;
 - void solve() {
 - int n, d;
 - cin >> n >> d;
 - string s;
 - cin >> s;
 - for (int i = 0; i < n; ++i) {
 - if (s[i] - '0' >= d) {
 - cout << s[i];
 - } else {
 - cout << d;
 - for (int j = i; j < n; ++j) {
 - cout << s[j];
 - }
 - cout << endl;
 - return;
 - }
 - }
 - cout << d << endl;
 - }
 - int32_t main() {
 - ios_base::sync_with_stdio(0);
 - cin.tie(0);
 - int t;
 - cin >> t;
 - while (t--) {
 - solve();
 - }
 - return 0;
 - }
 


No comments