Advertisement
Guest User

T3

a guest
Apr 3rd, 2013
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int n, k;
  8. int a[200000];
  9. int main()
  10. {
  11.     cin >> n >> k;
  12.     string s = "", s1 ="";
  13.     if (k > n)
  14.     {
  15.         cout << -1;
  16.         return 0;
  17.     }
  18.     if (n == 1)
  19.     {
  20.         cout << 'a';
  21.         return 0;
  22.     }
  23.     if (k == 1)
  24.     {
  25.         cout << -1;
  26.         return 0;
  27.     }
  28.     n = n - k + 1;
  29.     for (int i = k - 1; i > 1; --i)
  30.         s = (char)('a' + i) + s;
  31.     for (int i = 0; i <= n; ++i)
  32.         s1 = s1 + (char)('a' + (i % 2));
  33.     s = s1 + s;
  34.     cout << s;
  35.  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement