51nod2000 四边形分割平面 规律题

观察样例,$ans(1) = 1, ans(2) = 10$,再手推一组,$ans(3) = 26$

可以发现规律$ans(n) = (2n - 1)^2 + 1$

如果还是没看出规律,那么打个程序去骗组数据

更明显了,是吧.....

证明很简单,懒得证了

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

extern inline char gc() {
    static char RR[23456], *S = RR + 23333, *T = RR + 23333;
    if(S == T) fread(RR, 1, 23333, stdin), S = RR;
    return *S ++;
}
inline int read() {
    int p = 0, w = 1; char c = gc();
    while(c > '9' || c < '0') { if(c == '-') w = -1; c = gc(); }
    while(c >= '0' && c <= '9') p = p * 10 + c - '0', c = gc();
    return p * w;
}

#define ll long long
#define ri register int

int main() {
    int Tt = read();
    for(ri i = 1; i <= Tt; i ++) {
        int n = 2 * read() - 1;
        printf("%lld
", 1ll * n * n + 1);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/reverymoon/p/9560649.html