B - Save the problem! CodeForces - 867B 构造题

这个题目还是很简单的,很明显是一个构造题,但是早训的时候脑子有点糊涂,想到了用1 2 来构造,

但是去算这个数的时候算错了。。。

用1 2 来构造

可以先枚举一些数来找找规律。

1 1 

2 2

3 1 1 1    2 1 1  

4 ....

可以发现每一个数都是 n/2+1 的可能,

所以反过来推过去就是 (s-1)*2  或者(s-1)*2+1

这个(s-1)*2+1的答案才是正确答案 因为 这个s可以==1 

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <iostream>
#include <string>
#define inf 0x3f3f3f3f
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
const int maxn = 1e5 + 10;
typedef long long ll;

int main()
{
    int n;
    scanf("%d", &n);
    printf("%d 2\n", (n - 1) * 2 + 1);
    printf("1 2\n");
    return 0;
}
View Code

猜你喜欢

转载自www.cnblogs.com/EchoZQN/p/11404128.html