1. 程式人生 > >51nod2000 四邊形分割平面 規律題

51nod2000 四邊形分割平面 規律題

esp == namespace ext 明顯 string span def clu

技術分享圖片

觀察樣例,$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\n", 1ll * n * n + 1); } return 0; }

51nod2000 四邊形分割平面 規律題