I 've written an error on the second classic version of The lrj algorithm, and I thought about it for a long time...
V: number of points, E: number of sides F: Number of faces
Euler's formula v-e + F = 2;
V = N + N/4 sum (I * (N-2-I); [0 <= I <= N-2];
E = N + n/2 sum (I * (N-2-I) + 1); [0 <= I <= N-2];
Code implementation:
# Include <cstdio> # include <cstring> # include <iostream> # include <algorithm> # include <vector> # include <stack> # include <queue> # include <map> # include <set> # include <list> # include <cmath> # include <string> # include <sstream> # include <ctime> using namespace STD; # DEFINE _ pI ACOs (-1.0) # define Inf (1 <10) # define ESP 1e-9typedef long ll; typedef unsigned long ull; typedef pair <int, int> pill; /* ===================================================== ========================================================== ========= */ll _ V (ll n) {/* vertex */ll ans = 0; For (ll I = 0; I <= N-2; I ++) ans = ans + I * (N-2-I); ll _ ans = N + N * ANS/4; return _ ans;} ll _ E (LL N) {/* plane x/ll ans = 0; For (ll I = 0; I <= N-2; I ++) ans = ans + (I * (N-2-I) + 1); ll _ ans = N + N * ANS/2; return _ ans;} int main () {int t; scanf ("% d", & T); While (t --) {ll N; scanf ("% i64d", & N ); ll v = _ V (n); ll e = _ E (n); printf ("% i64d \ n", 1 + E-V);} return 0 ;}