Advertisement
sherry_ahmos

Untitled

Apr 4th, 2023
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <string.h>
  5. #include <math.h>
  6. #include <set>
  7. #include <stack>
  8. #include <queue>
  9. #include <bits/stdc++.h>
  10.  
  11. using namespace std;
  12.  
  13. #define ll long long
  14. #define cy cout << "YES\n"
  15. #define cn cout << "NO\n"
  16. #define nl "\n"
  17. #define fi first
  18. #define se second
  19. #define MOD 1000000007
  20. #define all(v) v.begin(), v.end()
  21. #define rall(v) v.end(), v.begin()
  22.  
  23. #define sz(s) s.size()
  24. #define f0r(j, n) for (ll i = j; i < n; i++)
  25. template <typename T = int>
  26. istream &operator>>(istream &in, vector<T> &v)
  27. {
  28.     for (auto &x : v)
  29.         in >> x;
  30.     return in;
  31. }
  32.  
  33. template <typename T = int>
  34. ostream &operator<<(ostream &out, const vector<T> &v)
  35. {
  36.     for (const T &x : v)
  37.         out << x << " ";
  38.     return out;
  39. }
  40.  
  41. void sherry()
  42. {
  43.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  44. #ifndef ONLINE_JUDGE
  45.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  46. #endif
  47. }
  48. /*
  49. int gcd(ll a, ll b)
  50. {
  51.     if (b == 0)
  52.         return a;
  53.     return (b, a % b);
  54. }
  55. */
  56.  
  57. void solve()
  58. {
  59.     int n, m;
  60.     cin >> n >> m;
  61.     string s;
  62.     bool flag = 0;
  63.     cin >> s;
  64.     for (int i = 0; i < sz(s); i++)
  65.     {
  66.         if (s[i] - '0' < m and flag == 0)
  67.         {
  68.             cout << m;
  69.             flag = 1;
  70.         }
  71.         cout << s[i];
  72.     }
  73.     if (flag == 0)
  74.         cout << m;
  75.     cout << nl;
  76. }
  77. int main()
  78. {
  79.     sherry();
  80.     int t = 1;
  81.     cin >> t;
  82.     while (t--)
  83.         solve();
  84.     return 0;
  85. }
  86. //
Tags: insert digit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement