#include
#define ios ios::sync_with_stdio(0),cin.tie(0)
#define fi first
#define se second
#define pb push_back
#define PII pair<int,int>
#define int long long
using namespace std;
const int N = 1e7 + 1,M = N * 2,INF = 0x3f3f3f3f,mod = 998244353;
int a[N],b[N];
void solve()
{
string s,res; cin >> s;
for(int i = s.size() - 1;i >= 0;i --)
res += s[i];
s += res;
cout << s << endl;
}
signed main()
{
ios;
int T = 1;cin >> T;while(T -- ) solve();
return 0;
}
#include
#define ios ios::sync_with_stdio(0),cin.tie(0)
#define fi first
#define se second
#define pb push_back
#define PII pair<int,int>
#define int long long
using namespace std;
const int N = 1e7 + 1,M = N * 2,INF = 0x3f3f3f3f,mod = 998244353;
int a[N],b[N];
int n;
void solve()
{
cin >> n;
if(n == 1) cout << "1" << endl;
else
{
if(n & 1)
{
for(int i = 1;i <= n;i ++ ) cout << "1" << ' ';
cout << endl;
}
else
{
if(n == 2)
{
cout << "1 3" <<endl;
}
else
{
cout << "1 2 3" << ' ';
for(int i = 1;i <= n - 3;i ++ ) cout << "2" << ' ';
cout << endl;
}
}
}
}
signed main()
{
ios;
int T = 1;cin >> T;while(T -- ) solve();
return 0;
}
#include
#define ios ios::sync_with_stdio(0),cin.tie(0)
#define fi first
#define se second
#define pb push_back
#define PII pair<int,int>
#define int long long
using namespace std;
const int N = 2e5 + 1000,M = N * 2,INF = 0x3f3f3f3f,mod = 998244353;
int ans[N];
int p[N];
bool st[N];
vector<int> res2;
int cnt;
void prime(int x)
{
int res=0;
for(int i=2;i<=x;i++)
{
if(!st[i])
{
p[cnt++]=i;
}
for(int j=0;p[j]<=x/i;j++)
{
st[p[j]*i]=true;
if(i%p[j]==0)break;
}
}
}
void check(int x)
{
for(int i = 2;i * i <= x ;i ++ )
{
if(x % i == 0)
{
while(x % i == 0)
{
x /= i;
res2.pb(i);
}
}
if(x == 1) break;
}
if(x != 1) res2.pb(x);
}
void solve()
{
int n,x;
cin >> n >> x;
res2.clear();
if(x == n)
{
cout << x << ' ';
for(int i = 2;i <= n - 1;i ++ )
cout << i <<' ';
cout << "1" << endl;
}
else
{
if(n % x != 0) cout << "-1" << endl;
else
{
// 只有x这个位置需要变化
int w = n;
for(int i = 2;i <= n - 1;i ++ )
ans[i] = i;
int k = n / x;
check(k);
// for(auto o:res2) cout << o << ' ';
cout << x << ' ';
for(int i = res2.size() - 1;i >= 0;i -- )
{
ans[w / res2[i]] = w;
w /= res2[i];
}
for(int i = 2;i <= n - 1;i ++ )
cout << ans[i] << ' ';
cout << "1" <<endl;
}
}
}
signed main()
{
ios;
int T = 1;cin >> T;while(T -- ) solve();
return 0;
}
#include
#define ios ios::sync_with_stdio(0),cin.tie(0)
#define fi first
#define se second
#define pb push_back
#define PII pair<int,int>
#define int long long
using namespace std;
const int N = 2e5 + 1000,M = N * 2,INF = 0x3f3f3f3f,mod = 998244353;
void solve()
{
int n; cin >> n;
if(n == 2) // 特判
{
cout << "1 3" << endl;
return;
}
int k = (n + 1) * (n + 1);
for(int l = 1;l <= n;l ++ )
{
int r = 1 + n + l;
int le = (l + n - 2) * (l + n - 1) / 2 - l * (l + 1) / 2; // 等差数列求和
int ri = r * (r - 1) / 2 - (r - n + 1) * (r - n + 2) / 2; // 等差数列求和
if((k - r - l) >= le && (k - r - l) <= ri)
{
cout << l << ' ';
int s = k - r - l;
int d = n - 2; // 最多选d个数字
for(int i = l + 1;i <= r - 1;i ++ ) // 判断该数字是否可用,如果可用的话,那剩下的必须选择的数字的和也一定要在新的范围内
{
if(d == 0) break;
int w = s - i; //如果选i的话,剩下的和
int d1 = d - 1;// 剩下的个数
int ll =(i + d1) * (i + d1 + 1) / 2 - i * (i + 1) / 2,rr = (r - 1) * (r) / 2 - (r - 1 - d1) *(r - 1 - d1 + 1) / 2;
if(w >= ll && w <= rr) // 必须在该范围内
{
cout << i << ' ';
s = w;
d = d1;
}
}
cout << r << endl;
break;
}
}
}
signed main()
{
ios;
int T = 1;cin >> T;while(T -- ) solve();
return 0;
}
这此打的不好,脑溢血了,c题那个求质因数的函数,因为懒没有自己写,而是用了以前写过的那个,谁知道以前写的那个不对,一直在调试,重点:不要懒还有 d 题,判断数字是否可用的时候,我已经通过样例知道 写的有问题,但是我以为就4一个特殊的,然后就没继续想,然后就wa了,真的别懒