#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using Pll = pair; using Pii = pair; const double PI = acos(-1.0); const double EPS = 1e-10; vector< complex > dft(int n, vector< complex > f, bool inv) { if(n == 1) { return f; } while(f.size() < n) f.push_back( complex(0.0, 0.0) ); vector< complex > ff[2]; for(int i=0;i zeta(cos(theta), sin(theta)); complex pow_zeta(1.0, 0.0); for(int i=0;i > convolution(vector< complex > g, vector< complex > h) { int n_pow2 = 1; while(n_pow2 <= int(g.size()+h.size())) n_pow2 <<= 1; vector< complex > inv_g = dft(n_pow2, g, false); vector< complex > inv_h = dft(n_pow2, h, false); vector< complex > inv_f(n_pow2, complex(0.0, 0.0)); for(int i=0;i> to_vec(ll n) { vector> v; while(n) { v.push_back(complex(n % 10, 0)); n /= 10; } return v; } ll calc_digit_sum(ll n) { ll ret = 0LL; while(n) { ret += n % 10; n /= 10; } return ret; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; ll p; vector> mul = to_vec(1); for(int i=0;i> p; vector> v = to_vec(p); while(v.size() < mul.size()) v.push_back(complex(0, 0)); mul = convolution(mul, v); } int carry = 0; for(int j=0;j(carry%10, 0)); carry /= 10; } ll digit_sum = 0LL; for(int i=0;i= 10) { digit_sum = calc_digit_sum(digit_sum); } cout << digit_sum << endl; }