#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> #include<map> #include<set> #include<vector> #include<queue> #include<stack> //#include<bits/std c++.h> using namespace std; typedef long long LL; typedef unsigned long long ULL; const LL MOD = 1e7 + 7; const LL maxn = 1e6 + 131; const LL Bits = 1e10; const double Pi = acos(-1.0); struct BigInt { vector<LL> val; void Set(LL n) { val.clear(); val.push_back(n); } void operator += (const BigInt a) { int i; for(i = 0; i < val.size() && i < a.val.size() ; ++i) val[i] = val[i] + a.val[i]; if(i < a.val.size()) for(; i < a.val.size(); ++i) val.push_back(a.val[i]); int len = val.size(); for(i = 0; i < len; ++i) { if(val[i] >= Bits) { if(i == len-1) val.push_back(val[i]/Bits), val[i] %= Bits; else { val[i+1] += (val[i] / Bits); val[i] %= Bits; } } } } void operator *= (const LL k) { int i; for(i = 0; i < val.size(); ++i) val[i] *= k; i = 0; while(i != val.size()) { if(val[i] >= Bits) { if(i == val.size() -1) { val.push_back(val[i] / Bits); val[i] %= Bits; } else { val[i+1] += (val[i] / Bits); val[i] %= Bits; } } ++i; } } void operator /= (const LL k) { for(int i = val.size() - 1; i >= 1; --i) { val[i-1] += (val[i] % k)*Bits; val[i] /= k; } val[0] /= k; int i = val.size() - 1; while(val.size() > 1) { if(val[i] == 0) val.erase(--val.end()); else break; i--; } } void Show() { cout << val[val.size() - 1]; for(int i = val.size() - 2; i >= 0 ; --i) { LL k = Bits / 10; while( k > 1 ) { if(val[i] < k) cout << "0"; k /= 10; } cout << val[i]; } cout << endl; } }; int main() { BigInt A, B; LL n; /*A.Set(1), B.Set(Bits - 1); A += B; A.Show();*/ //cout << Pi << endl; while(cin >> n){ if(n < 4) cout << "1\n"; else { n -= 4; A.Set(1), B.Set(1); LL i = 1, j = (n + Pi), Last; while(i <= (LL)((n + Pi)/ Pi)) { Last = j; j = (n + Pi - i*Pi); for(LL k = Last - 1; k >= j + 1; k--) { B *= (k+1); B /= (i + k); } B *= (j + 1); B /= i; i ++; A += B; } A.Show(); } } return 0; }
时间: 2024-10-21 20:13:34