题意

codeforces1328B_字符串组数据,每次给你两个数codeforces1328B_ios_02,问你由codeforces1328B_字符串_03codeforces1328B_ios_04codeforces1328B_字符串_05codeforces1328B_ios_06组成的字符串的第codeforces1328B_#define_07小的字典序的字符串是什么。


思路

我们通过观察可以知道规律,1+2+3+…+n,符合前codeforces1328B_字符串_08项和的部分规律,第codeforces1328B_#define_07个串由两个codeforces1328B_ios_06的位置唯一确定,由后往前找第一个codeforces1328B_ios_06的位置,这个位置就是前codeforces1328B_字符串_08项和大于codeforces1328B_#define_07的位置,第二个位置就是前codeforces1328B_ios_14项和与codeforces1328B_#define_07的差,详细见代码。

参考代码

#include <bits/stdc++.h>
using namespace std;
#define
#define
#define
#define
#define
#define
const double pi = acos(-1.0);
const double eps = 1e-9;
typedef long long LL;
const int N = 1e6 + 10;
const int M = 1e5 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double f = 2.32349;
void solve() {
IOS;
int t;
cin >> t;
while (t--) {
LL n, k;
cin >> n >> k;
int x = 0, y = 0;
while (1) {
y++;
x = y * (y + 1) / 2;
if (x >= k) {
break;
}
}
x = y * (y - 1) / 2;
x = k - x;
cout << x << " " << y << endl;
y = n - y;
x = n + 1 - x;
cout << x << " " << y << endl;
for (int i = 1; i <= n; i++) {
if (i == x || i == y) {
cout << "b";
} else {
cout << "a";
}
}
cout << endl;
}
}
signed main() {
solve();
return 0;
}