样例过了,在Codeforces里面WA了第二个点
#include <bits/stdc++.h>
#define int long long
#define iostream() ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
using namespace std;
const int maxn = 1e6+7;
const int MAXN = maxn / 2;
signed main()
{
iostream();
int n;
cin >> n;
string s;
cin >> s;
s = " " + s;
if (n % 2 == 0)
{
for (int i = 1; i <= n; i++)
{
if (i % 2 == 0 && i != n)
cout << s[i] << '-';
else
cout << s[i];
}
cout << '\n';
}
else if (n % 3 == 0)
{
for (int i = 1; i <= n; i++)
{
if (i % 3 == 0 && i != n)
cout << s[i] << '-';
else
cout << s[i];
}
cout << '\n';
}
else
{
int tmp = 1,fn = n;
while (n > 3)
{
for (int i = 1; i <= 2; i++)
{
if (i % 2 == 0)
cout << s[i] << '-';
else
cout << s[i];
tmp++;
}
n -= 2;
}
printf("%c%c%c",s[n - 2],s[n - 1],s[n]);
}
return 0;
}