ACM学习历程—UESTC 1226 Huatuo's Medicine(数学)(2015CCPC L)

题目链接:http://acm.uestc.edu.cn/#/problem/show/1226

题目就是构造一个对称的串,除了中间的那个只有1个,其余的两边都是对称的两个,自然答案就是2*n-1

代码:

#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\n", times, 2*n-1);
    }
    return 0;
}
View Code

 

posted on 2015-11-26 12:20  AndyQsmart  阅读(153)  评论(0编辑  收藏  举报

导航