Josif_tepe

Untitled

Feb 7th, 2026
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. using namespace std;
  7.  
  8.  
  9. int main() {
  10.     string s;
  11.     cin >> s;
  12.    
  13.     int n;
  14.     cin >> n;
  15.    
  16.     string a[n];
  17.    
  18.     bool ok = true;
  19.     for(int i = 0; i < n; i++) {
  20.         cin >> a[i];
  21.        
  22.         if(s == a[i]) {
  23.             ok = false;
  24.         }
  25.     }
  26.    
  27.     if(ok) {
  28.         cout << s << endl;
  29.         return 0;
  30.     }
  31.    
  32.     for(int i = 1; i <= 201; i++) {
  33.         string str = "";
  34.         int x = i;
  35.         while(x > 0) {
  36.             str += (x % 10) + '0';
  37.             x /= 10;
  38.         }
  39.         reverse(str.begin(), str.end());
  40.        
  41.         string tmp = s + str;
  42.        
  43.         bool moze = true;
  44.         for(int j = 0; j < n; j++) {
  45.             if(tmp == a[j]) {
  46.                 moze = false;
  47.             }
  48.         }
  49.        
  50.         if(moze) {
  51.             cout << tmp << endl;
  52.             break;
  53.         }
  54.        
  55.     }
  56.    
  57.     return 0;
  58. }
  59.  
  60. /// YNYYYNYNY
  61.  
Advertisement
Add Comment
Please, Sign In to add comment