# How to judge whether an Activity is displayed at the top

2023-03-16

Problem：
There are n points on an ellipse, connecting them, and asking how many parts can be divided into.
solution：
There are n points, and a circle is divided into n parts.

Detailed deduction process:

and the amount of data in the title requires us to use high -precision operations.
High -precision operation template:http://blog.csdn.net/cfarmerreally/article/details/52123946

note:
To do more questions, master a lot of questions and then look back.

#include<cstdio>
#include<iostream>
#include<sstream>
#include<cstdlib>
#include<cmath>
#include<cctype>
#include<string>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<vector>
#include<fstream>
#include<list>
using namespace std;

#define ms(s) memset(s,0,sizeof(s))
typedef unsigned long long ULL;
typedef long long LL;

const int INF = 0x3fffffff;

const int maxLen = 1005;
struct BigInt{
//not support negative
long long num[maxLen];
int digit = 0;

BigInt() = default;
BigInt(char a[]){
int la = strlen(a);
int i = la-8, j = 0;

for(; i >= 0; i -= 8)
sscanf(a+i,"%8d",&num[j++]);
int t;  num[j] = 0;
if(i+8 > 0){
for(int k = 0; i+8 > 0; ++k){
sscanf(a+k,"%1d",&t);
num[j] = num[j]*10 + t;
--i;
}
++j;
}
num[j] = -1;  digit = j;
}
BigInt(int a){
int j = 0;
num[j++] = a%100000000;
if(a >= 100000000)
num[j++] = a/100000000;
num[j] = -1;  digit = j;
}
BigInt(long long a){
int j = 0;
num[j++] = a%100000000;
a /= 100000000;
if(a > 0){
num[j++] = a%100000000;
a /= 100000000;
if(a > 0){
num[j++] = a%100000000;
}
}
num[j] = -1;  digit = j;
}

int bigCmp(const BigInt rhs){
if(digit > rhs.digit)
return 1;
else if(digit < rhs.digit)
return -1;
else{
for(int i = digit-1; i >= 0; --i){
if(num[i] > rhs.num[i])
return 1;
else if(num [i] < rhs.num[i])
return -1;
}
return 0;
}
}

BigInt operator + (const BigInt rhs){
BigInt ans;  int idx = 0, carry = 0;

while(num[idx]!=-1 && rhs.num[idx]!=-1){
ans.num[idx] = num[idx]+rhs.num[idx]+carry;
carry = ans.num[idx] / 100000000;
ans.num[idx++] %= 100000000;
}
if(num[idx] != -1){
while(num[idx] != -1){
ans.num[idx] = num[idx] + carry;
carry = ans.num[idx] / 100000000;
ans.num[idx++] %= 100000000;
}
}
else{
while(rhs.num[idx] != -1){
ans.num[idx] = rhs.num[idx] + carry;
carry = ans.num[idx] / 100000000;
ans.num[idx++] %= 100000000;
}
}
if(carry > 0)
ans.num[idx++] = carry;
ans.num[idx] = -1;
ans.digit = idx;

return ans;
}

BigInt operator * (const int rhs){
BigInt ans;  int carry = 0,idx = 0;

if(rhs != 0){
for(idx = 0; num[idx] != -1; ++idx){
ans.num[idx] = num[idx]*rhs + carry;
carry = ans.num[idx] / 100000000;
ans.num[idx] %= 100000000;
}
if(carry > 0)
ans.num[idx++] = carry;
}
else{
ans.num[idx++] = 0;
}
ans.num[idx] = -1;
ans.digit = idx;
return ans;
}

BigInt operator - (const BigInt rhs){
//l >= r
BigInt ans;
int idx = 0, carry = 0;
while(rhs.num[idx] != -1){
ans.num[idx] = num[idx] - rhs.num[idx] - carry;
carry = 0;
if(ans.num[idx] < 0){
ans.num[idx] += 100000000;
carry = 1;
}
++idx;
}
while(num[idx] != -1){
ans.num[idx] = num[idx] - carry;
carry = 0;
if(ans.num[idx] < 0){
ans.num[idx] += 100000000;
carry = 1;
}
++idx;
}
ans.num[idx] = -1;
ans.digit = idx;
return ans;
}

void frac(int n){
num[0] = 1;  num[1] = -1;  digit = 1;
int carry, idx;
for(int i = 2; i <= n; ++i){
carry = 0;
for(idx = 0; num[idx] != -1; ++idx){
num[idx] = num[idx]*i + carry;
carry = num[idx] / 100000000;
num[idx] %= 100000000;
}
if(carry > 0)
num[idx++] = carry;
num[idx] = -1;
digit = idx;
}
}

long long operator % (const int rhs){
int idx = digit-1;
long long r = num[idx--]%rhs;
while(idx >= 0){
r = (r*100000000LL+num[idx])%rhs;
--idx;
}
return r;
}

BigInt operator / (const int rhs){
BigInt ans;
int i = digit-1, r = 0;
while(i >= 0){
ans.num[i] = (num[i]+r*100000000LL)/(long long)rhs;
r = (num[i]+r*100000000LL)%(long long)rhs;
--i;
}
ans.digit = digit;
while(ans.digit > 1 && ans.num[ans.digit-1] == 0)
ans.digit--;
ans.num[ans.digit] = -1;
return ans;
}

void Print(){
if(digit > 0){
int i = digit-1;
printf("%lld",num[i]);
while(i--)
printf("%08lld",num[i]);
printf("\n");
}
}
};

int main(){
//    freopen("F:\\input.txt","r",stdin);
//    freopen("F:\\output.txt","w",stdout);
//    ios::sync_with_stdio(false);

int s;
LL n;
scanf("%d",&s);
BigInt ans;
while(s--){
scanf("%lld",&n);
ans = (((BigInt(n)*n)*n)*n+(BigInt(n)*n)*23+BigInt(24)-((BigInt(n)*n)*n)*6-BigInt(n)*18)/24;
ans.Print();
}

return 0;
}


source