Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- #define ll long long int
- const int M = 1e9 + 7;
- int main() {
- int t;
- cin >> t;
- while (t--) {
- int n, x;
- cin >> n >> x;
- string s;
- cin >> s;
- int req = n; // changed here
- if (x == 0) {
- s.insert(n, "0"); // changed here
- cout << s << endl;
- }
- //int p = stoi(s[i])
- else {
- vector<int> digits;
- for (auto x : s)
- digits.push_back(x - '0');
- for (int i = 0; i < n; ++i) {
- if (digits[i] < x) {
- req = i;
- break;
- }
- }
- string y;
- y = to_string(x);
- s.insert(req, y);
- cout << s << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement