题目链接:http://acm.uestc.edu.cn/#/problem/show/1226
题目就是构造一个对称的串,除了中间的那个只有1个,其余的两边都是对称的两个,自然答案就是2*n-1。
代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <algorithm> #include <set> #include <map> #include <queue> #include <string> #define LL long long using namespace std; int main() { //freopen("test.in", "r", stdin); int n, T; scanf("%d", &T); for (int times = 1; times <= T; ++times) { scanf("%d", &n); printf("Case #%d: %d ", times, 2*n-1); } return 0; }