Advertisement
Guest User

Codechef PERPALIN Solution

a guest
Nov 12th, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. void solve() {
  6.     int N, P;
  7.     cin >> N >> P;
  8.    
  9.     if (P == 1 || P == 2) {
  10.         cout << "impossible\n";
  11.         return;
  12.     }
  13.    
  14.     string p = "a" + string(P - 2, 'b') + "a";
  15.     for (int i = 0; i < N / P; i++)
  16.         cout << p;
  17.     cout << "\n";
  18. }
  19.  
  20. int main() {
  21.     int num_tests;
  22.     cin >> num_tests;
  23.    
  24.     for (int test_id = 0; test_id < num_tests; test_id++) {
  25.         solve();
  26.     }
  27.    
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement