#include <iostream>
#include <assert.h>
const int terms = 10;
constexpr int factorial(int n)
{
return n <= 1 ? 1 : (n * factorial(n-1));
}
constexpr double pow(double x,int n){
return n==0? 1 : (n==1? x : x*pow(x,n-1));
}
constexpr double exp(double x,int n){
return n == terms ? pow(x,n)/factorial(n): pow(x,n)/factorial(n)+ exp(x,n+1);
}
using namespace std;
static const double alpha = 3.0;
template <int N>
struct Table {
Table<N - 1> rest;
const double x;
Table() : x(exp(N*alpha,0)) {}
double operator[](size_t i){
assert(i < N);
return (reinterpret_cast<double*>(this))[i];
}
};
template <>
struct Table<0> {
const double x;
Table() : x(1) {}
double operator[](size_t i){
assert(i < 1);
return (reinterpret_cast<double*>(this))[i];
}
};
int main() {
Table<10> t;
for(int i=0;i<10;i++)
cout << t[i] << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YXNzZXJ0Lmg+Cgpjb25zdCBpbnQgdGVybXMgPSAxMDsKY29uc3RleHByIGludCBmYWN0b3JpYWwoaW50IG4pCnsKICAgIHJldHVybiBuIDw9IDEgPyAxIDogKG4gKiBmYWN0b3JpYWwobi0xKSk7Cn0KY29uc3RleHByIGRvdWJsZSBwb3coZG91YmxlIHgsaW50IG4pewoJcmV0dXJuIG49PTA/IDEgOiAobj09MT8geCA6IHgqcG93KHgsbi0xKSk7ICAJCn0KCmNvbnN0ZXhwciBkb3VibGUgZXhwKGRvdWJsZSB4LGludCBuKXsKCXJldHVybiAJbiA9PSB0ZXJtcyA/ICBwb3coeCxuKS9mYWN0b3JpYWwobik6IHBvdyh4LG4pL2ZhY3RvcmlhbChuKSsgZXhwKHgsbisxKTsgCn0KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnN0YXRpYyBjb25zdCBkb3VibGUgYWxwaGEgPSAzLjA7CnRlbXBsYXRlIDxpbnQgTj4Kc3RydWN0IFRhYmxlIHsKICAgIFRhYmxlPE4gLSAxPiByZXN0OwogICAgY29uc3QgZG91YmxlIHg7CiAgIC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