[C++]segment tree
this problem can be solved by using segment tree\n\n\'\'\'\ntypedef long long ll;\nclass ProductOfNumbers {\n\n    public:\n\n    int a[40005];\n    ll tree[400
this problem can be solved by using segment tree\n\n\'\'\'\ntypedef long long ll;\nclass ProductOfNumbers {\n\n    public:\n\n    int a[40005];\n    ll tree[40005 << 2];\n    int n;\n    \n    ll query(int l , int r , int x , int y , int id){\n        if(l > r || x > r || y < l)return 1;\n        if(l <= x && y <= r){\n            return tree[id];\n        }\n        int mid = (x + y) >> 1;\n        if(mid < l)\n            return query(l , r , mid + 1 , y , id << 1 | 1);\n        if(mid >= r)\n            return query(l , r , x , mid , id << 1 );\n        return query(l , r , x , mid , id << 1 ) * query(l , r , mid + 1 , y , id << 1 | 1);\n    }\n    \n    void update(int l , int r , int pos , ll val , int id){\n        if(l > r || pos < l || pos > r)return;\n        if(l == r && l == pos){\n            tree[id] = val;\n        }\n        else{\n            int mid = (l + r) >> 1;\n            update(l , mid , pos , val , id << 1);\n            update(mid + 1 , r , pos , val , id << 1 | 1);\n            tree[id] = tree[id << 1] * tree[id << 1 | 1];\n        }\n    }\n    \n    ProductOfNumbers() {\n        n = 0;\n        memset(tree , 1 , sizeof(1));\n    }\n    \n    void add(int num) {\n        a[++n] = num;\n        update(1 , 40003 , n , num , 1);\n    }\n    \n    int getProduct(int k) {\n        return query(n - k + 1 , n , 1 , 40003 , 1);\n    }\n};\n\n\'\'\'
[]